The Terraform Module Structure I Use for Every AWS Project
If you've worked on more than one AWS project with Terraform, you've probably hit this wall: what starts as a clean main.tf slowly turns into hundreds of lines of spaghetti — mixing networking, IAM...

Source: DEV Community
If you've worked on more than one AWS project with Terraform, you've probably hit this wall: what starts as a clean main.tf slowly turns into hundreds of lines of spaghetti — mixing networking, IAM, compute, and databases in one place. I've seen this pattern repeated across multiple teams. The fix isn't working harder — it's structuring your modules the right way from day one. In this article, I'll walk you through the exact Terraform module structure I use for every AWS project, why each decision was made, and the mistakes it prevents. Why module structure matters more than you think Terraform is infrastructure-as-code, which means all the same software engineering principles apply: separation of concerns, reusability, and avoiding duplication. A poor module structure leads to: State file conflicts when multiple engineers work simultaneously Inability to reuse code across environments (dev/staging/prod) Blast radius issues — a change in one area accidentally destroying another Slow te