Terraform Starter Kit: Terraform Best Practices Guide
Terraform Best Practices Guide A field-tested collection of patterns for writing maintainable, secure, and team-friendly Terraform configurations. These practices come from managing production AWS ...

Source: DEV Community
Terraform Best Practices Guide A field-tested collection of patterns for writing maintainable, secure, and team-friendly Terraform configurations. These practices come from managing production AWS infrastructure across dozens of projects. 1. Project Structure The single most impactful decision is how you organize files. A flat directory with everything in main.tf works for tutorials but breaks down fast in real projects. Recommended layout: project/ ├── backend.tf # Provider and backend config ├── variables.tf # All input variables ├── outputs.tf # All outputs ├── terraform.tfvars # Variable values (git-ignored) ├── modules/ │ ├── vpc/ │ ├── ecs/ │ └── rds/ └── environments/ ├── dev/main.tf # Composes modules for dev └── prod/main.tf # Composes modules for prod Why separate environments into directories instead of workspaces? Workspaces share the same backend config and state bucket key prefix. If you need different provider configurations, different module versions, or different backe