What breaks first at scale
- Copy-pasted modules with hidden differences.
- Shared state files across unrelated workloads.
- Manual cloud changes causing IaC drift.
- No policy checks before apply.
- Version changes rolled out without dependency planning.
Reference structure that works
- Module repository: reusable, versioned building blocks.
- Environment repository: dev/stage/prod composition and variables.
- Pipeline layer: plan/apply controls, approvals, and audit trails.
- Policy layer: enforce security and compliance rules.
Module design principles
- Keep modules focused and single-purpose.
- Use explicit input/output contracts.
- Document default behaviors and risks.
- Pin provider and module versions.
- Ship module examples and integration tests.
Drift control strategy
- Run scheduled plan in read-only mode for drift visibility.
- Alert on critical resource drift.
- Block manual production changes outside emergency process.
- Require drift issue closure before major releases.
Governance checklist
- Remote state with locking and encryption.
- Separate state per environment and workload boundary.
- Policy checks for networking, IAM, encryption, and tagging.
- Break-glass procedure with audit logs.
- Quarterly module deprecation and upgrade plan.
FAQ
Monorepo or multirepo for Terraform?
Either can work. Prioritize clear ownership and release boundaries.
How often should modules be versioned?
Version on any breaking change and communicate migration steps.
Should apply be fully automated?
For lower-risk environments yes; production usually needs guarded approvals.
Can drift be fully prevented?
Not fully. The goal is rapid drift detection and controlled remediation.
Next action
Audit your current Terraform repositories and map top drift and module-governance risks in one backlog.