Interview Prep/Terraform/Modules and Code Structure

A monorepo has 40 stacks. How do you structure layers and blast radius?

AdvancedScenarioModules and Code Structure
Answer

Situation read → One giant state means slow plans and a huge blast radius.

What I'd do →

  1. Layer by change frequency and ownership: foundation (accounts, IAM, DNS), network, data, platform (EKS), apps.
  2. One state per layer per environment.
  3. Pass values downward through SSM parameters or remote state outputs.
  4. Gate each layer with CODEOWNERS and separate apply roles.

Why → Slow-changing, high-impact layers get strict review; fast-changing app layers deploy often and can't break the network.

Interview tip → Say how apps discover infrastructure: data sources and tags, not hardcoded IDs.

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure