Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created Apr 13, 2018
Embed
What would you like to do?
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