# Moving from Terraform Monorepo to Multi-Repo Without Losing Your Mind (and Your Sleep)

Published: (December 11, 2025 at 03:55 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

The Problem

MetricMonorepoMulti‑Repo
Average plan time68 min1.8 min (97 % faster)
Failed runs per week270.8 (97 % reduction)
PR merge time4.2 h18 min (93 % faster)
Largest state file1.9 GB38 MB
Engineer happiness4.8/109.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-version constraints
  • Backend configuration pointing to dedicated S3 + DynamoDB tables
  • README.md, CODEOWNERS, and pre‑commit hooks

Upgrade Tooling

FromTo
Terraform 1.5 + Terraform CloudOpenTofu 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

MetricBeforeAfter
Average plan time68 min1.8 min
Failed runs per week270.8
PR merge time4.2 h18 min
Largest state file1.9 GB38 MB
Engineer happiness4.8/109.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)

Back to Blog

Related posts

Read more »