Skip to content

Instantly share code, notes, and snippets.

@emmanuel
Created June 16, 2017 22:57
Show Gist options
  • Save emmanuel/04f8a3845a1819195994d88ae6d86dd0 to your computer and use it in GitHub Desktop.
Save emmanuel/04f8a3845a1819195994d88ae6d86dd0 to your computer and use it in GitHub Desktop.
apply: $(BUILD)/terraform.tfplan
$(TERRAFORM) apply $<
rm $<
destroy: init
destroy: $(BUILD)/terraform.tfvars $(BUILD)/destroy.tfplan
cd $(BUILD) && \
$(TERRAFORM) destroy -var-file=$<
rm $(BUILD)/destroy.tfplan
destroy/plan: $(BUILD)/destroy.tfplan
rm $<
plan: $(BUILD)/terraform.tfplan
init: $(BUILD)/.terraform/terraform.tfstate
$(BUILD)/terraform.tfplan: $(BUILD)/terraform.tfvars $(BUILD)/.terraform/terraform.tfstate
cd $(BUILD); \
$(TERRAFORM) plan \
-input=false \
-out=$@ \
-var-file=$<
$(BUILD)/destroy.tfplan: $(BUILD)/terraform.tfvars $(BUILD)/.terraform/terraform.tfstate
cd $(BUILD); \
$(TERRAFORM) plan \
-destroy \
-input=false \
-out=$@ \
-var-file=$<
$(BUILD)/.terraform/terraform.tfstate: | $(BUILD)
$(TERRAFORM) init \
-backend=true \
-backend-config=bucket=$(S3_BUCKET_NAME) \
-backend-config=key=$(APP_ENV)/applications/concourse/terraform.tfstate \
-get=true \
-input=false \
$(PWD) \
$(BUILD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment