Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created April 13, 2018 01:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/0baa2b52359df178ae793de38e046afd to your computer and use it in GitHub Desktop.
Save matschaffer/0baa2b52359df178ae793de38e046afd to your computer and use it in GitHub Desktop.
Terraform makefile
SHELL = /bin/bash
terraform_opts ?=
terraform_plan_opts ?=
.PHONY: help
help::
@echo
@echo Infrastructure management using Terraform.
@echo
@echo "## Common management tasks:"
@echo
@echo "init - initializes state and loads modules"
@echo "clean - removes initialized state and modules"
@echo "plan - shows changes to be applied"
@echo "apply - shows changes to be applied, prompts for confirmation, then applies if confirmed"
@echo "destroy - shows items to destroy, prompts for confirmation, then destroys if confirmed"
@echo
.PHONY: install-providers
install-providers::
@true
.PHONY: init
init: install-providers
@terraform init -get=true -input=false
.PHONY: clean
clean:
rm -rf .terraform
.PHONY: plan
plan: install-providers
@terraform plan $(terraform_plan_opts) $(terraform_opts)
.PHONY: apply
apply: install-providers
@terraform apply -auto-approve=false $(terraform_plan_opts) $(terraform_opts)
.PHONY: destroy
destroy: install-providers
@terraform destroy $(terraform_plan_opts) $(terraform_opts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment