|
| 1 | +.PHONY: help test init plan apply destroy fmt validate lint security clean install-tools |
| 2 | + |
| 3 | +help: |
| 4 | + @echo "Available targets:" |
| 5 | + @echo " test - Run all tests" |
| 6 | + @echo " install-tools - Install testing dependencies" |
| 7 | + @echo " init - Initialize Terraform" |
| 8 | + @echo " plan - Show execution plan" |
| 9 | + @echo " apply - Apply infrastructure changes" |
| 10 | + @echo " destroy - Destroy infrastructure" |
| 11 | + @echo " fmt - Format Terraform files" |
| 12 | + @echo " validate - Validate configuration" |
| 13 | + @echo " lint - Run tflint" |
| 14 | + @echo " security - Run security scan" |
| 15 | + @echo " clean - Clean up generated files" |
| 16 | + |
| 17 | +test: |
| 18 | + @./tests/test-terraform.sh |
| 19 | + |
| 20 | +install-tools: |
| 21 | + @chmod +x tests/install-tools.sh |
| 22 | + @./tests/install-tools.sh |
| 23 | + |
| 24 | +init: |
| 25 | + terraform init |
| 26 | + |
| 27 | +plan: init |
| 28 | + terraform plan |
| 29 | + |
| 30 | +apply: test |
| 31 | + ./safe-apply.sh |
| 32 | + |
| 33 | +destroy: |
| 34 | + terraform destroy |
| 35 | + |
| 36 | +fmt: |
| 37 | + terraform fmt -recursive |
| 38 | + |
| 39 | +validate: init |
| 40 | + terraform validate |
| 41 | + |
| 42 | +lint: |
| 43 | + @if command -v tflint >/dev/null 2>&1; then \ |
| 44 | + tflint --config tests/.tflint.hcl --init; \ |
| 45 | + tflint --config tests/.tflint.hcl; \ |
| 46 | + else \ |
| 47 | + echo "tflint not installed. Run: make install-tools"; \ |
| 48 | + exit 1; \ |
| 49 | + fi |
| 50 | + |
| 51 | +security: |
| 52 | + @if command -v checkov >/dev/null 2>&1; then \ |
| 53 | + checkov -d . --config-file tests/.checkov.yaml; \ |
| 54 | + else \ |
| 55 | + echo "checkov not installed. Run: make install-tools"; \ |
| 56 | + exit 1; \ |
| 57 | + fi |
| 58 | + |
| 59 | +clean: |
| 60 | + rm -rf .terraform |
| 61 | + rm -f .terraform.lock.hcl |
| 62 | + rm -f terraform.tfstate |
| 63 | + rm -f terraform.tfstate.backup |
| 64 | + rm -f plan.tfplan |
| 65 | + rm -rf generated/ |
0 commit comments