-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (60 loc) · 2.43 KB
/
Makefile
File metadata and controls
73 lines (60 loc) · 2.43 KB
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
68
69
70
71
72
73
.PHONY: fmt-tf fmt-tf-check \
test-tf test-tf-modules test-tf-stacks test-tf-module test-tf-stack \
validate-tf validate-tf-modules validate-tf-stacks validate-tf-module validate-tf-stack
# Terraform formatting
TF_MODULES := $(wildcard terraform/modules/*/*)
TF_STACKS := $(wildcard terraform/stacks/*)
# Format all Terraform files
fmt-tf:
terraform fmt -recursive terraform/
# Check Terraform formatting (CI-friendly, fails if unformatted)
fmt-tf-check:
terraform fmt -recursive -check terraform/
# Run all Terraform tests (modules + stacks)
test-tf: test-tf-modules test-tf-stacks
# Test all modules
test-tf-modules:
@for dir in $(TF_MODULES); do \
echo "=== Testing $$dir ==="; \
terraform -chdir=$$dir init -backend=false -input=false && \
terraform -chdir=$$dir test || exit 1; \
done
# Test all stacks
test-tf-stacks:
@for dir in $(TF_STACKS); do \
echo "=== Testing $$dir ==="; \
terraform -chdir=$$dir init -backend=false -input=false && \
terraform -chdir=$$dir test || exit 1; \
done
# Test a specific module: make test-tf-module PROVIDER=aws MODULE=vpc
test-tf-module:
terraform -chdir=terraform/modules/$(PROVIDER)/$(MODULE) init -backend=false -input=false
terraform -chdir=terraform/modules/$(PROVIDER)/$(MODULE) test
# Test a specific stack: make test-tf-stack STACK=aws-ec2
test-tf-stack:
terraform -chdir=terraform/stacks/$(STACK) init -backend=false -input=false
terraform -chdir=terraform/stacks/$(STACK) test
# Run terraform validate (modules + stacks)
validate-tf: validate-tf-modules validate-tf-stacks
# Validate all modules
validate-tf-modules:
@for dir in $(TF_MODULES); do \
echo "=== Validating $$dir ==="; \
terraform -chdir=$$dir init -backend=false -input=false && \
terraform -chdir=$$dir validate || exit 1; \
done
# Validate all stacks
validate-tf-stacks:
@for dir in $(TF_STACKS); do \
echo "=== Validating $$dir ==="; \
terraform -chdir=$$dir init -backend=false -input=false && \
terraform -chdir=$$dir validate || exit 1; \
done
# Validate a specific module: make validate-tf-module PROVIDER=aws MODULE=vpc
validate-tf-module:
terraform -chdir=terraform/modules/$(PROVIDER)/$(MODULE) init -backend=false -input=false
terraform -chdir=terraform/modules/$(PROVIDER)/$(MODULE) validate
# Validate a specific stack: make validate-tf-stack STACK=aws-ec2
validate-tf-stack:
terraform -chdir=terraform/stacks/$(STACK) init -backend=false -input=false
terraform -chdir=terraform/stacks/$(STACK) validate