Makefile
ACCOUNT=$(shell aliyun sts GetCallerIdentity | jq -r '.AccountId')
BASE_NAME=$(shell basename $(CURDIR))
REGION="cn-hongkong-b"
init:
terraform init \
-backend-config="bucket=tf-${ACCOUNT}" \
-backend-config="key=${BASE_NAME}" \
-backend-config="region=${REGION}"
inits3:
@echo -n "Create OSS bucket: 'tf-${ACCOUNT}'? [y/N] " && read ans && [ $${ans:-N} = y ]
aliyun oss mb "oss://tf-${ACCOUNT}"
fmt:
terraform fmt -write=true --recursive
validate:
terraform validate
plan:
terraform plan -input=false -out=tfplan-${ACCOUNT}
apply:
terraform apply -input=false tfplan-${ACCOUNT}
destroy:
terraform plan -destroy -input=false -out=tfplan-${ACCOUNT}
terraform apply -input=false tfplan-${ACCOUNT}
Common
main.tf
data.tf
variables.tf