Last active
May 15, 2016 14:38
-
-
Save k-kinzal/b77c47fdcbfeba7b6f93ec980b226b04 to your computer and use it in GitHub Desktop.
Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: apply plan destroy clean | |
UNAME_S := $(shell uname -s) | |
TMP_DIR := $(shell mktemp -d -t '') | |
profile ?= default | |
target ?= imiew-com kinzal-net logn-in other | |
apply: | |
find base ${target} -name '*.tf' | xargs -J% cp -n % ${TMP_DIR} | |
cp -n *.tf *.tfstate ${TMP_DIR} | |
terraform apply -var "profile=${profile}" ${TMP_DIR} | |
plan: | |
find base ${target} -name '*.tf' | xargs -J% cp -n % ${TMP_DIR} | |
cp -n *.tf *.tfstate ${TMP_DIR} | |
terraform plan -var "profile=${profile}" ${TMP_DIR} | |
destroy: | |
find base ${target} -name '*.tf' | xargs -J% cp -n % ${TMP_DIR} | |
cp -n *.tf *.tfstate ${TMP_DIR} | |
terraform destroy -var "profile=${profile}" -var 'destroy_protection=false' ${TMP_DIR} | |
clean: | |
rm -f terraform.tfstate | |
rm -f terraform.tfstate.backup | |
rm -fR .terraform/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
region = "${var.region}" | |
profile = "${var.profile}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "profile" { | |
default = "default" | |
} | |
variable "region" { | |
default = "ap-northeast-1" | |
} | |
variable "prefix" { | |
default = "" | |
} | |
variable "suffix" { | |
default = "" | |
} | |
variable "shell" { | |
default = false | |
} | |
variable "destroy_protection" { | |
default = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment