Skip to content

Instantly share code, notes, and snippets.

@sylwit
Created July 18, 2020 15:31
Show Gist options
  • Save sylwit/b1668f355e5772f2c95a62f408f80689 to your computer and use it in GitHub Desktop.
Save sylwit/b1668f355e5772f2c95a62f408f80689 to your computer and use it in GitHub Desktop.
Terraform with aw-vault template
account := acc
VARS_ENV="variables/$(TF_WORKSPACE).tfvars"
VARS_SECRETS="variables/$(TF_WORKSPACE)-secrets.tfvars"
fmt:
terraform fmt
workspace:
aws-vault exec $(account) -- terraform workspace list
init:
aws-vault exec $(account) -- terraform init
plan: check-env
aws-vault exec $(account) -- \
terraform plan \
-var-file=$(VARS_ENV) \
-var-file=$(VARS_SECRETS)
apply: check-env
aws-vault exec $(account) -- \
terraform apply \
-var-file=$(VARS_ENV) \
-var-file=$(VARS_SECRETS)
check-env:
ifndef TF_WORKSPACE
$(error TF_WORKSPACE is undefined)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment