Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize Environment Configuration Based on locals.tf #4

Open
jsandov opened this issue Nov 20, 2024 · 0 comments
Open

Parameterize Environment Configuration Based on locals.tf #4

jsandov opened this issue Nov 20, 2024 · 0 comments
Assignees
Labels
effort/medium 2-3 days of work priority/medium Medium priority scope/terraform Related to Terraform type/refactor

Comments

@jsandov
Copy link

jsandov commented Nov 20, 2024

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

  1. Use local.environment for:

    • Environment tag
    • Module environment parameter
  2. Use local.domain_name for:

    • Module domain_name parameter
    • S3 bucket name
    • Base for logs bucket name
  3. 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}"
}
@jonathan-d-nguyen jonathan-d-nguyen added priority/medium Medium priority scope/terraform Related to Terraform type/refactor effort/medium 2-3 days of work labels Dec 2, 2024
@jonathan-d-nguyen jonathan-d-nguyen self-assigned this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium 2-3 days of work priority/medium Medium priority scope/terraform Related to Terraform type/refactor
Projects
None yet
Development

No branches or pull requests

2 participants