Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions aws/network/modules/vpc-endpoints/s3-vpc-endpoint/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
15 changes: 10 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ export TFDOCSRC := $(CURDIR)/.terraform-docs.yml

SUBMODULES := $(filter-out \
%.md,\
$(wildcard \
platform/modules/* \
platform \
aws/*/modules/*\
aws/* \
$(foreach dir,\
$(wildcard \
platform/modules/* \
platform \
aws/*/modules/* \
aws/* \
platform/modules/*/* \
aws/*/modules/*/* \
),\
$(if $(wildcard $(dir)/*.tf),$(dir),)\
)\
)
SUBMODULEMAKEFILES := $(foreach module,$(SUBMODULES),$(module)/makefile)
Expand Down
Loading