Skip to content

Instantly share code, notes, and snippets.

Created Apr 13, 2018
What would you like to do?
Terraform makefile
SHELL = /bin/bash
terraform_opts ?=
terraform_plan_opts ?=
.PHONY: help
@echo Infrastructure management using Terraform.
@echo "## Common management tasks:"
@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"
.PHONY: install-providers
.PHONY: init
init: install-providers
@terraform init -get=true -input=false
.PHONY: 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