Skip to content

Route Makefile.terraform frontend-only through scripts/tf-deploy.sh (unify deploy paths) #59

Open

Description

@cristim

Problem

After PR LeanerCloud/cloud-commitments-cli#1244 lands, scripts/tf-deploy.sh forwards arbitrary extra arguments verbatim to terraform, so -target=... is now a first-class capability of the script. The frontend-only target in Makefile.terraform, however, still bypasses the script and invokes terraform directly:

frontend-only: ## Deploy frontend only
	@echo "🎨 Deploying frontend..."
	@cd terraform/environments/$(PROVIDER)/$(PROFILE) && \
		terraform apply -var-file="../../../profiles/$(PROVIDER)/$(PROFILE).tfvars" -target=module.frontend

So this one target skips:

  • the colored banner / log_info / "Deployment Outputs" summary the script prints on success
  • the profile-existence validation (if [ ! -f "$PROFILE_FILE" ])
  • the environment-directory bootstrap (creates ${ENV_DIR} and symlinks main.tf if missing)
  • the terraform init auto-run when .terraform is absent
  • the AWS_PROFILE warning

A user who happens to run make frontend-only first will get a different (worse) experience than someone who runs make deploy first then make frontend-only. The duplication also means the path-arithmetic (../../../profiles/...) lives in two places.

Fix

Route frontend-only through the script now that the script supports -target=...:

frontend-only: ## Deploy frontend only
	@echo "🎨 Deploying frontend..."
	@./scripts/tf-deploy.sh $(PROVIDER) $(PROFILE) apply -target=module.frontend

Quick verification:

make -n -f Makefile.terraform frontend-only
# expect: ./scripts/tf-deploy.sh aws dev apply -target=module.frontend

And with a stub terraform on PATH the recorded invocation should be:

apply -var-file=<.../aws/dev.tfvars> -target=module.frontend

Out-of-scope for PR LeanerCloud/cloud-commitments-cli#1244

PR LeanerCloud/cloud-commitments-cli#1244 intentionally limited itself to dropping vestigial targets and fixing the silent argument drop. This unification is a small, safe follow-up that becomes possible because of LeanerCloud/cloud-commitments-cli#1244.

References

Activity

  1. IAmJSD commented on Oct 23, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. self-assigned this
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions