Interview Prep/Terraform/Modules and Code Structure

Teams complain a "VPC module" has 90 variables and still doesn't do what they need. How do you fix the design?

IntermediateScenarioModules and Code Structure
Answer

Situation read → A God module that tries to cover every case.

What I'd do →

  1. Split by concern: network core, NAT, endpoints, flow logs.
  2. Offer opinionated defaults and a few feature flags.
  3. Group optional settings in typed objects.
  4. Add examples/ showing the three common shapes.

Why → Smaller modules compose; each has a small interface, and consumers swap parts without forking.

Interview tip → If a module needs a count for every resource, it's trying to do too much.

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure