You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
As Terraform projects grow, adopting best practices for code organisation, collaboration, security, and CI/CD becomes essential. This lesson consolidates recommendations for running Terraform in production teams.
| File | Purpose |
|---|---|
main.tf | Primary resource definitions |
variables.tf | Input variable declarations |
outputs.tf | Output value declarations |
providers.tf | Provider configuration and requirements |
backend.tf | Backend configuration |
locals.tf | Local value definitions |
data.tf | Data source definitions |
versions.tf | Version constraints (sometimes combined with providers.tf) |
infrastructure/
├── modules/ # Reusable modules
│ ├── network/
│ ├── compute/
│ ├── database/
│ └── monitoring/
├── environments/ # Environment configurations
│ ├── development/
│ ├── staging/
│ └── production/
├── .gitignore # Ignore state files, .terraform/
├── .terraform.lock.hcl # Committed — pins provider versions
└── README.md
# Terraform
.terraform/
*.tfstate
*.tfstate.backup
*.tfvars # May contain secrets
crash.log
override.tf
override.tf.json
*_override.tf
*_override.tf.json
Always pin provider versions to avoid unexpected changes:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.