Monorepos¶
Using TerraTidy in repositories with multiple Terraform modules.
Setup¶
Initialize a monorepo configuration:
This creates a .terratidy.yaml with:
- Central
./policiesdirectory for shared OPA policies ciprofile (all engines enabled)developmentprofile (lint and policy disabled for speed)
Config Placement¶
Place .terratidy.yaml at the repository root. TerraTidy processes files relative to the current working directory:
repo/
.terratidy.yaml # Root config
policies/ # Shared OPA policies
modules/
networking/
main.tf
variables.tf
compute/
main.tf
variables.tf
environments/
staging/
main.tf
production/
main.tf
Running Checks¶
Specific modules¶
All modules¶
Changed files only¶
This checks all modified .tf/.hcl/.tfvars files across the entire repo.
Profile-Based Workflows¶
Local development (fast)¶
CI/CD (thorough)¶
Production deployment gate¶
Module Overrides¶
Override rules for specific modules using config imports:
# .terratidy.yaml
version: 1
imports:
- ./modules/networking/.terratidy-overrides.yaml
engines:
style:
enabled: true
# modules/networking/.terratidy-overrides.yaml
overrides:
rules:
style.terraform-files-structure:
enabled: false # Networking module uses a different structure
CI Integration¶
Run checks per module in parallel CI jobs: