-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (62 loc) · 2.35 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.PHONY: .tf_version
ifneq ($(CI), true)
include .env
endif
DATESTRING := $(shell date +%FT%H-%M-%S)
TF_VERSION := $(shell cat .tf_version)
.DEFAULT_GOAL := help
TF_DIR = tf/$(ENVIRONMENT)
.EXPORT_ALL_VARIABLES:
export TF_VERSION=${TF_VERSION}
## init: terraform init
init: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --workdir /app/$(TF_DIR) terraform init
## init-upgrade: terraform init -upgrade
init-upgrade: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --workdir /app/$(TF_DIR) terraform init -upgrade
## fmt: terraform fmt -recursive
fmt: .env
docker compose run --rm --workdir /app terraform fmt -recursive
## ci-fmt: terraform fmt -recursive -check -diff -write=false
ci-fmt:
touch .env
docker compose run --rm --workdir /app terraform fmt -recursive -check -diff -write=false
## plan: terraform plan
plan: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --workdir /app/$(TF_DIR) terraform plan
## plan-print: terraform plan -no-color | tee plan-<date>.out
plan-print: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --workdir /app/$(TF_DIR) terraform plan -no-color | tee plan-${DATESTRING}.out
## apply: terraform apply
apply: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --workdir /app/$(TF_DIR) terraform apply
## validate: terraform validate across all environments
validate:
docker compose run --rm --workdir /app terraform init -backend=false
docker compose run --rm --workdir /app terraform validate -json
## destroy: terraform destroy
destroy: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --workdir /app/$(TF_DIR) terraform destroy
## tf-shell: opens a shell inside the terraform container
tf-shell: .env
docker compose run --rm envvars ensure --tags terraform
docker compose run --rm --entrypoint='' terraform /bin/ash
## pull: docker-compose pull
pull:
docker compose pull
## docs: generate terraform module docs
docs:
docker compose run --rm terraform-docs terraform-docs .
## .env: creates .env file with the envvar keys populated
.env:
touch .env
docker compose run --rm envvars envfile --overwrite --example
## help: show this help
help:
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)