-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
47 lines (37 loc) · 1.17 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
TF_DIRS = $(patsubst %/main.tf, %, $(shell find . -type d -name .terraform -prune -o -name 'main.tf' -print))
VALIDATE_TF_DIRS = $(addprefix validate-,$(TF_DIRS))
LINT_TF_DIRS = $(addprefix lint-,$(TF_DIRS))
DOCS_TF_DIRS = $(addprefix docs-,$(TF_DIRS))
# Generate docs for a terraform directories
$(DOCS_TF_DIRS): docs-%:
@echo "Docs $*"
terraform-docs --config docs/.terraform-docs.yaml $*
terraform-docs --config docs/.terraform-docs-example.yaml $*
# Generate docs
.PHONY: docs
docs: $(DOCS_TF_DIRS)
@echo "All docs generated"
# Format all terraform files
fmt:
terraform fmt -recursive
# Check if all terraform files are formatted
fmt-check:
terraform fmt -recursive -check
# Validate a terraform directories
$(VALIDATE_TF_DIRS): validate-%:
@echo "Validate $*"
terraform -chdir="$*" init -upgrade
terraform -chdir="$*" validate
# Validate all terraform directories
validate: $(VALIDATE_TF_DIRS)
@echo "All validated"
# Lint a terraform directories
$(LINT_TF_DIRS): lint-%:
@echo "Lint $*"
tflint --config "$(PWD)/.tflint.hcl" --chdir="$*"
# Initialize tflint
lint-init:
tflint --init
# Lint all terraform directories
lint: lint-init $(LINT_TF_DIRS)
@echo "All linted"