Skip to content

Commit 0d148b2

Browse files
committed
makefile
1 parent 54c705b commit 0d148b2

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ terraform validate
5353
terraform test
5454
```
5555

56+
You can also run the local aggregate target:
57+
58+
```bash
59+
make check
60+
```
61+
5662
For example changes, also run the same init and validate commands from the touched example directory.
5763

5864
Do not run `terraform apply`, `terraform destroy`, or destructive state commands unless the user explicitly asks for them and confirms the target environment.

Makefile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
SHELL := /bin/bash
2+
3+
EXAMPLES := $(wildcard examples/*)
4+
5+
.PHONY: help fmt fmt-check docs docs-check init validate test examples-init examples-validate check hooks
6+
7+
help:
8+
@echo "Available targets:"
9+
@echo " make fmt Format all Terraform files"
10+
@echo " make fmt-check Check Terraform formatting"
11+
@echo " make docs Generate README Terraform docs"
12+
@echo " make docs-check Check README Terraform docs are current"
13+
@echo " make init Initialize the root module"
14+
@echo " make validate Validate the root module"
15+
@echo " make test Run native Terraform tests"
16+
@echo " make examples-init Initialize all examples"
17+
@echo " make examples-validate Validate all examples"
18+
@echo " make check Run local CI-style checks"
19+
@echo " make hooks Enable repo-local Git hooks"
20+
21+
fmt:
22+
terraform fmt -recursive
23+
24+
fmt-check:
25+
terraform fmt -check -recursive
26+
27+
docs:
28+
scripts/terraform-docs.sh
29+
30+
docs-check:
31+
scripts/terraform-docs.sh --check
32+
33+
init:
34+
terraform init -backend=false
35+
36+
validate:
37+
terraform validate
38+
39+
test:
40+
terraform test -no-color
41+
42+
examples-init:
43+
@for example in $(EXAMPLES); do \
44+
if [ -d "$$example" ]; then \
45+
echo "Initializing $$example"; \
46+
terraform -chdir="$$example" init -backend=false; \
47+
fi; \
48+
done
49+
50+
examples-validate:
51+
@for example in $(EXAMPLES); do \
52+
if [ -d "$$example" ]; then \
53+
echo "Validating $$example"; \
54+
terraform -chdir="$$example" validate; \
55+
fi; \
56+
done
57+
58+
check: fmt-check docs-check init validate test examples-init examples-validate
59+
60+
hooks:
61+
git config core.hooksPath .githooks

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ terraform test
142142

143143
Pull requests run the same tests through `.github/workflows/terraform-pr.yml`, along with formatting, generated-docs, validation, and example checks.
144144

145+
## Local Development
146+
147+
Use the Makefile for common local checks:
148+
149+
```bash
150+
make fmt
151+
make docs
152+
make check
153+
```
154+
145155
## Notes
146156

147157
- The module does not create VPC, subnet, route table, NAT gateway, or security baseline resources.

0 commit comments

Comments
 (0)