Terraform¶
Shell Functions¶
Helper functions expect this directory structure per stack:
Initialize¶
Runs terraform init -reconfigure -backend-config=environments/dev.s3.tfbackend.
Plan¶
Runs terraform plan -var-file environments/dev.tfvars.
Apply¶
Destroy¶
Clean Up¶
Removes .terraform.lock.hcl and .terraform/ directories from the current tree.
Task Automation¶
Init with Dynamic Backend¶
Automatically resolves the S3 bucket name from the current AWS account:
terraform init -reconfigure -backend-config="bucket=tf-state-$(aws sts get-caller-identity | jq -r .Account)"
Plan with Sandbox Vars¶
Runs plan with environments/sandbox.tfvars.
Aliases¶
| Alias | Command |
|---|---|
tf |
terraform |
tffmt |
terraform fmt -recursive |
Provider Cache¶
Terraform providers are cached globally to avoid re-downloading:
Prompt Integration¶
Starship shows the current Terraform workspace and version in the prompt when you're in a directory with .tf files.