-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (34 loc) · 1.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Configuration variables.
TERRAFORM_VERSION := 0.9.9
AWS_REGION := us-east-1
AWS_PROFILE := andrewriess
# Launch Terraform in a isolated docker container.
TERRAFORM := docker run --rm -it -e AWS_PROFILE=${AWS_PROFILE} -e AWS_REGION=${AWS_REGION} -v ~/.aws:/root/.aws -v ${PWD}:/data -w /data hashicorp/terraform:${TERRAFORM_VERSION}
# Syncing the website to S3 bucket.
sync:
AWS_PROFILE=${AWS_PROFILE} aws s3 sync ./src/ s3://andrew-riess-site/ --exclude ".dir"
# Invalidates cache from cloudfront.
invalidate:
AWS_PROFILE=${AWS_PROFILE} aws cloudfront create-invalidation --distribution-id E1J14L7SYWOM2A \
--paths "/*"
# Syncs with S3 and clears cloudfront cache.
full: sync invalidate
echo "andrewriess.com has been updated!"
# Initialize the Terraform backend.
init:
rm -rf .terraform && \
${TERRAFORM} init \
-backend=true \
-backend-config="bucket=andrew-riess-terraform" \
-backend-config="key=terraform.tfstate" \
-backend-config="region=${AWS_REGION}" \
-backend-config="profile=${AWS_PROFILE}" \
-force-copy
# Planning will sync the landing page to s3,
# initialize Terraform backend and then do a Terraform plan.
plan: init
${TERRAFORM} plan -var="aws_region=${AWS_REGION}" -out=.terraform/terraform.tfplan
# Run a Terraform apply against the plan that was ran. It will also do a little
# cleanup and remove any zip files it created.
apply:
${TERRAFORM} apply .terraform/terraform.tfplan