-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
60 lines (43 loc) · 1.4 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
# Defaults
REV:=$(shell git rev-parse --short HEAD)
DATE:=$(shell date +%Y.%m.%d-%H.%M.%S)
BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
COMMIT:=$(MODULE)_$(INFRA_VALUES)_$(DATE)_$(REV)
CURRENT_DIR_PATH:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Terraform Setup
TF_MODULE_PATH:=example
TF_PLAN_FILE:=$(TF_MODULE_PATH)_$(REV)
.PHONY: clean
pre-commit: clean
pre-commit install
pre-commit install-hooks
pre-commit run --all-files --show-diff-on-failure
install:
tfenv install
init:
terraform -chdir=$(TF_MODULE_PATH) init
upgrade: clean
terraform -chdir=$(TF_MODULE_PATH) init -upgrade
validate:
terraform -chdir=$(TF_MODULE_PATH) validate
plan: validate
terraform -chdir=$(TF_MODULE_PATH) plan \
-out=$(TF_PLAN_FILE).tfplan
plan-destroy: validate
terraform -chdir=$(TF_MODULE_PATH) plan \
-destroy \
-out=$(TF_PLAN_FILE).tfplan
apply: validate
terraform -chdir=$(TF_MODULE_PATH) apply
apply-auto-approve: validate
terraform -chdir=$(TF_MODULE_PATH) apply -auto-approve
apply-plan:
terraform -chdir=$(TF_MODULE_PATH) apply $(TF_PLAN_FILE).tfplan
destroy: validate
terraform -chdir=$(TF_MODULE_PATH) destroy
destroy-auto-approve: validate
terraform -chdir=$(TF_MODULE_PATH) destroy -auto-approve
clean:
find . -name "*.terraform" -type d -exec rm -rf {} + || true
find . -name "*.terraform.lock.hcl" -type f -delete || true
find . -name "*.tfplan" -type f -delete || true