-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (70 loc) · 2.99 KB
/
Makefile
File metadata and controls
85 lines (70 loc) · 2.99 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
74
75
76
77
78
79
80
81
82
83
84
85
# Makefile for GitHub Foundations Organizations Layer
# This provides convenient commands for testing, formatting, and validation
.PHONY: help init test format format-check lint validate security clean all
help: ## Show this help message
@echo "GitHub Foundations Organizations Layer - Development Commands"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
init: ## Initialize Terraform
@echo "Initializing Terraform..."
cd organizations && terraform init
test: init ## Run Terraform tests
@echo "Running Terraform tests..."
cd organizations && terraform test -verbose
format: ## Format Terraform and Terragrunt files
@echo "Formatting Terraform files..."
cd organizations && terraform fmt -recursive
@echo "Formatting Terragrunt files..."
cd organizations && terragrunt hclfmt
format-check: ## Check if Terraform and Terragrunt files are formatted
@echo "Checking Terraform formatting..."
cd organizations && terraform fmt -check -diff -recursive
@echo "Checking Terragrunt formatting..."
cd organizations && terragrunt hclfmt --terragrunt-check --terragrunt-diff
validate: init ## Validate Terraform configuration
@echo "Validating Terraform configuration..."
cd organizations && terraform validate
lint: ## Run TFLint on Terraform files (requires tflint)
@echo "Running TFLint..."
@if command -v tflint >/dev/null 2>&1; then \
cd organizations && tflint --init && tflint --recursive; \
else \
echo "TFLint not installed. Install from: https://github.com/terraform-linters/tflint"; \
exit 1; \
fi
security: ## Run security scan with Trivy (requires trivy)
@echo "Running security scan..."
@if command -v trivy >/dev/null 2>&1; then \
trivy config organizations/; \
else \
echo "Trivy not installed. Install from: https://aquasecurity.github.io/trivy/"; \
exit 1; \
fi
clean: ## Clean Terraform artifacts
@echo "Cleaning Terraform artifacts..."
find organizations -type d -name ".terraform" -exec rm -rf {} + 2>/dev/null || true
find organizations -type d -name ".terragrunt-cache" -exec rm -rf {} + 2>/dev/null || true
find organizations -type f -name ".terraform.lock.hcl" -delete 2>/dev/null || true
pre-commit-install: ## Install pre-commit hooks
@echo "Installing pre-commit hooks..."
@if command -v pre-commit >/dev/null 2>&1; then \
pre-commit install; \
echo "Pre-commit hooks installed successfully!"; \
else \
echo "pre-commit not installed. Install with: pip install pre-commit"; \
exit 1; \
fi
pre-commit-run: ## Run pre-commit hooks on all files
@echo "Running pre-commit hooks..."
@if command -v pre-commit >/dev/null 2>&1; then \
pre-commit run --all-files; \
else \
echo "pre-commit not installed. Install with: pip install pre-commit"; \
exit 1; \
fi
all: format validate test ## Run format, validate, and test
check: format-check validate test ## Run format check, validate, and test (for CI)
.DEFAULT_GOAL := help