This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
60 lines (49 loc) · 1.37 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
.PHONY: build-ami deploy-ami plan apply destroy graph clean
-include .mikado.conf.mk
-include .aws_data.mk
.mikado.conf.mk:
@cat mikado.conf | sed 's/"//g ; s/=/:=/' > .mikado.conf.mk
.aws_data.mk:
@bash ./scripts/aws_data.sh | sed 's/"//g ; s/=/:=/' > .aws_data.mk
update:
@terraform get ./terraform
build-ami:
@packer build packer/wp.json 2>&1 | tee .packer-out.log
@$(MAKE) clean
deploy-ami:
@bash ./scripts/deploy_ami.sh
@$(MAKE) clean
# This target executes the terraform plan stage
# This will not change anything in you AWS setup only displays the changes
plan: update
@terraform plan \
-out ./.tfplan \
./terraform
# Once you happy with the output of make plan run this target
# This will change your remote resources
apply: plan
@while [ -z "$$CONTINUE" ]; do \
read -r -p "Dow you want to apply these changes? [y/N] " CONTINUE; \
done ; \
if [ ! $$CONTINUE == "y" ]; then \
if [ ! $$CONTINUE == "Y" ]; then \
echo "Exiting." ; exit 1 ; \
fi \
fi
@terraform apply \
./terraform
@$(MAKE) -s clean
graph: update
@terraform graph \
-draw-cycles ./terraform | dot -Tpng > graph.png
@$(MAKE) -s clean
# Don't run this
destroy: update
@terraform plan -destroy -out ./terraform.tfplan ./terraform/
@terraform apply ./terraform.tfplan
@$(MAKE) -s clean
clean:
@rm -rf ./.tmp
@rm -rf ./.terraform
@rm -f ./.mikado.conf.mk
@rm -f ./.aws_data.mk