Interview Prep/Terraform/Modules and Code Structure

When would you choose one root module with many modules over many small root modules (stacks)?

AdvancedScenarioModules and Code Structure
Answer

Situation read → Granularity of state is the real decision.

What I'd do →

  1. Single root when components are tightly coupled, deployed together and owned by one team.
  2. Separate roots when lifecycles, owners or blast radius differ, such as network vs app.
  3. Between roots, share through published outputs, not shared state files.

Why → One state gives atomic changes but slow plans and a large blast radius; many states give independence but need orchestration and contracts.

Interview tip → Frame it as lifecycle and ownership boundaries, not a file count.

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure