-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
effort/medium2-3 days of work2-3 days of workpriority/mediumMedium priorityMedium priorityscope/terraformRelated to TerraformRelated to Terraformtype/refactor
Description
Currently, there's duplication between locals.tf
values and module parameters. Values defined in locals should be used consistently throughout the configuration
Current Code
locals {
environment = "staging"
domain_name = "staging.jdnguyen.tech"
}
module "website" {
domain_name = "staging.jdnguyen.tech" # Duplicates locals.domain_name
environment = "staging" # Duplicates locals.environment
aws_s3_bucket_name = "staging.jdnguyen.tech" # Could use locals.domain_name
logs_bucket_name = "staging.logs.jdnguyen.tech" # Could derive from locals
}
Proposed Changes
-
Use
local.environment
for:- Environment tag
- Module environment parameter
-
Use
local.domain_name
for:- Module domain_name parameter
- S3 bucket name
- Base for logs bucket name
-
Update provider tags to use locals
Benefits
- Single source of truth
- Easier environment management
- Reduced chance of configuration errors
Implementation Note
Consider creating additional locals for derived values like logs bucket name:
locals {
logs_bucket_name = "staging.logs.${local.domain_name}"
}
Metadata
Metadata
Assignees
Labels
effort/medium2-3 days of work2-3 days of workpriority/mediumMedium priorityMedium priorityscope/terraformRelated to TerraformRelated to Terraformtype/refactor