-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
effort/large4-7 days of work4-7 days of workpriority/highHigh priorityHigh priorityscope/terraformRelated to TerraformRelated to Terraformtype/refactor
Description
Current State
All configuration is in main.tf
, mixing concerns:
- Backend configuration
- Provider settings
- Local variables
- Module configurations
- Outputs
Proposed File Structure
environments/staging/
├── backend.tf # S3 backend configuration
├── providers.tf # AWS provider configurations
├── locals.tf # Environment-specific variables
├── variables.tf # Input variables if needed
├── main.tf # Module instantiation only
└── outputs.tf # Output definitions
Migration Steps
- Move backend configuration to
backend.tf
- Separate provider configurations into
providers.tf
- Extract locals into
locals.tf
- Move outputs to
outputs.tf
- Keep only module instantiation in
main.tf
Benefits
- Better organization
- Easier maintenance
- Consistent with Terraform best practices
- Improved readability
- Easier git diff tracking
Implementation Example
# backend.tf
terraform {
backend "s3" {
bucket = "jdnguyen-terraform-state"
key = "staging/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-locks"
encrypt = true
}
}
Metadata
Metadata
Assignees
Labels
effort/large4-7 days of work4-7 days of workpriority/highHigh priorityHigh priorityscope/terraformRelated to TerraformRelated to Terraformtype/refactor