Home›Guides›Module structure

A module structure that scales: the standard layout

Most messy IaC repositories started as one folder that kept growing. The standard module structure is simple, and following it early saves a lot of untangling later.

The layout

my-module/
├── README.md
├── LICENSE
├── main.tf
├── variables.tf
├── outputs.tf
├── modules/
│   └── nested/
└── examples/
    └── basic/

Less copy-paste between environments

Since OpenTofu 1.8, variables and locals can be used in backend configuration and module sources, which removes a lot of repeated boilerplate per environment.

Signs your structure needs attention: the same module copied into several folders, provider and backend blocks pasted everywhere, and no examples anyone can run.

Examples use OpenTofu (tofu); in Terraform the commands start with terraform. Check the documentation for your version before relying on a feature.

Modules copied five times?We do this as a fixed-price job.IaC Health Check →

Book a 30-minute call

Tell us what you are trying to fix. No preparation needed.

Book a 30-minute call