# Moving from Terraform Monorepo to Multi-Repo Without Losing Your Mind (and Your Sleep)
Source: Dev.to
The Problem
| Metric | Monorepo | Multi‑Repo |
|---|---|---|
| Average plan time | 68 min | 1.8 min (97 % faster) |
| Failed runs per week | 27 | 0.8 (97 % reduction) |
| PR merge time | 4.2 h | 18 min (93 % faster) |
| Largest state file | 1.9 GB | 38 MB |
| Engineer happiness | 4.8/10 | 9.6/10 |
Single repo: 180 k LoC, 2 800 resources, state file 1.9 GB.
Multi‑repo: each team repo.
Example: extract team‑alpha state
terraform state mv -state-out=team-alpha.tfstate \
module.vpc module.team_alpha_vpc
terraform state mv -state-out=team-alpha.tfstate \
aws_eks_cluster.alpha null
Repeat for all 42 teams (automated via script).
Create New Repositories
An automated script creates each repo with:
- Correct
.terraform-versionconstraints - Backend configuration pointing to dedicated S3 + DynamoDB tables
README.md,CODEOWNERS, and pre‑commit hooks
Upgrade Tooling
| From | To |
|---|---|
| Terraform 1.5 + Terraform Cloud | OpenTofu 1.8 + Atlantis 4.0 |
Atlantis Configuration (YAML)
repos:
- id: /meenanukala/*
apply_requirements: [approved, mergeable]
workflow: tofu
workflows:
tofu:
plan:
steps:
- init
- plan:
extra_args: ["-lock-timeout=5m"]
apply:
steps:
- apply
Enforce Quality Gates
- Infracost + tfsec in every PR
- Custom pre‑commit hook that blocks state file commits
- Dependabot for provider updates
- Weekly automated drift detection
Results
| Metric | Before | After |
|---|---|---|
| Average plan time | 68 min | 1.8 min |
| Failed runs per week | 27 | 0.8 |
| PR merge time | 4.2 h | 18 min |
| Largest state file | 1.9 GB | 38 MB |
| Engineer happiness | 4.8/10 | 9.6/10 |
Resources
- Migration runbook & scripts –
- Includes state splitter script (handles nested modules)
- Repo creation template
- Atlantis + OpenTofu config
- Full migration runbook (PDF)
Monorepos made sense in 2018. By 2025 they’re technical debt with interest. If your Terraform plan takes longer than grabbing a coffee, it’s time to switch. Fork the repo above and follow the runbook.
— Meena Nukala, Senior DevOps Engineer (UK)