forked from thoughtbot/flightdeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
67 lines (52 loc) · 1.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
MODULEFILES := $(wildcard *.tf)
TFLINTRC ?= ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml
.PHONY: default
default: checkfmt validate docs lint
.PHONY: checkfmt
checkfmt: .fmt
.PHONY: fmt
fmt: $(MODULEFILES)
terraform fmt
@touch .fmt
.PHONY: validate
validate: .validate
.PHONY: docs
docs: README.md
.PHONY: lint
lint: .lint
.lint: $(MODULEFILES) .lintinit
tflint --config=$(TFLINTRC)
@touch .lint
.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC) --module
@touch .lintinit
README.md: $(MODULEFILES)
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md
.fmt: $(MODULEFILES)
terraform fmt -check
@touch .fmt
.PHONY: init
init: .init
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init
.validate: .init $(MODULEFILES) $(wildcard *.tf.example)
echo | cat - $(wildcard *.tf.example) > test.tf
if AWS_DEFAULT_REGION=us-east-1 terraform validate; then \
rm test.tf; \
touch .validate; \
else \
rm test.tf; \
false; \
fi
.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies
.PHONY: clean
clean:
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate