From babe2ef54d511240888b905836bf0904e5203357 Mon Sep 17 00:00:00 2001 From: "Benjamin Valiente (Contractor)" Date: Wed, 16 Sep 2026 19:52:58 -0600 Subject: [PATCH] fix: discover nested Terraform submodules in the SUBMODULES global --- .../vpc-endpoints/s3-vpc-endpoint/makefile | 67 +++++++++++++++++++ makefile | 15 +++-- 2 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 aws/network/modules/vpc-endpoints/s3-vpc-endpoint/makefile diff --git a/aws/network/modules/vpc-endpoints/s3-vpc-endpoint/makefile b/aws/network/modules/vpc-endpoints/s3-vpc-endpoint/makefile new file mode 100644 index 00000000..364a9e25 --- /dev/null +++ b/aws/network/modules/vpc-endpoints/s3-vpc-endpoint/makefile @@ -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 diff --git a/makefile b/makefile index 98378280..08445f24 100644 --- a/makefile +++ b/makefile @@ -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)