Multi-account & multi-region layouts

Structure a real estate.

Advanced14 min · lesson 9 of 12

The reason Terragrunt exists shows most clearly in a large layout: many accounts, many regions, many components. The convention is a live repository whose folder structure mirrors your real topology — account / region / environment / component — where each leaf is a small terragrunt.hcl unit, and hcl files at each level contribute shared config (the root has the backend, the account level has the provider/assume-role, the region level has the region, the env level has tags). Modules live in a separate repo, versioned.

live/ layout
live/
root.hcl # backend for all units
prod-account/
account.hcl # provider, assume-role for the prod account
us-east-1/
region.hcl # region + region-specific config
vpc/terragrunt.hcl
database/terragrunt.hcl
app/terragrunt.hcl
eu-west-1/ ...
dev-account/ ...
modules/ # separate, versioned Terraform modules repo

Why mirror the topology

Mapping folders to accounts/regions/components makes the estate navigable — the path tells you exactly what a unit is and where it deploys — and lets each level of the hierarchy own the config that belongs there (account credentials at the account level, region at the region level). path_relative_to_include() then derives unique state keys from that structure automatically. It is the layout that turns “hundreds of state files” from chaos into something a new engineer can read.

Separate the live (config) repo from the modules repo
Keep the versioned Terraform modules in their own repo and reference them by pinned ref from the live repo; mixing them means you cannot promote a tested module version through environments cleanly. The live repo says “prod uses module v1.4.0, dev uses v1.5.0-rc” — that separation is how you roll changes forward safely and roll back by changing a ref.