/terraform-apply -- Apply Terraform Changes
Trigger
User asks to apply Terraform changes for a stage.
Workflow
- •
Identify the stage. Valid stages:
- •
account-provision - •
account-setup - •
cloud-provision - •
vm-provision - •
k8s-provision - •
custom-stack-provision
If the user doesn't specify a stage, ask which one.
- •
- •
Confirm with the user -- applying makes real infrastructure changes. Summarize what will happen.
- •
Run the apply:
bashcd tf/<stage> && bash ../apply.sh
apply.shdoes the following automatically:- •Runs
terraform plan - •Runs
terraform apply - •Commits the state changes
- •Pushes to the
infraremote
- •Runs
- •
Review the output:
- •Confirm resources were created/modified/destroyed as expected
- •Note any errors
- •Verify the git commit and push succeeded
- •
Report results to the user.
Prerequisites
- •Mars CLI must be installed (check
.mars-version) - •Cloud credentials must be configured
- •
tf/auto-vars/common.auto.tfvars.jsonmust exist - •The
infragit remote must be configured (for auto-push)
Anti-patterns
- •Do not apply without user confirmation
- •Do not apply without reviewing the plan first
- •Do not ignore apply errors -- they may leave state in a partial state
- •Do not manually run
terraform apply-- always useapply.shto get the git commit/push
Checklist
- • Correct stage identified
- • User confirmed the apply
- •
apply.shexecuted from within the stage directory - • Output reviewed for errors
- • Git commit and push to
infraremote succeeded