Skip to content

Instantly share code, notes, and snippets.

@tomelliff
Created February 19, 2017 16:13
Show Gist options
  • Save tomelliff/cb6a829c38f69b27190c268bab679a5d to your computer and use it in GitHub Desktop.
Save tomelliff/cb6a829c38f69b27190c268bab679a5d to your computer and use it in GitHub Desktop.
Basic Makefile for Terraform to deploy Lambda functions
AWS_ACCOUNT_ID=`aws sts get-caller-identity --output text --query 'Account'`
bootstrap:
ifndef AWS_DEFAULT_REGION
$(error AWS_DEFAULT_REGION is not set)
endif
region_constraints='--region $(AWS_DEFAULT_REGION) --create-bucket-configuration LocationConstraint=$(AWS_DEFAULT_REGION)'; \
aws s3api create-bucket --bucket tfstate-lambda-functions-$(AWS_ACCOUNT_ID) $${region_constraints}
remote:
terraform remote config -backend="S3" \
-backend-config="bucket=tfstate-lambda-functions-$(AWS_ACCOUNT_ID)" \
-backend-config="key=s3-sftp-bridge-$(INTEGRATION_NAME)/state"
get:
terraform get -update=true
plan: get remote
terraform plan -input=false
apply: get remote
terraform apply -input=false
destroy: get remote
terraform destroy -input=false -force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment