Skip to content

Enhancement: Allow configurable naming of origin_access_control resources using each.value['name'] with fallback to each.key #160

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

Open
azuma317 opened this issue Apr 17, 2025 · 0 comments

Comments

@azuma317
Copy link

azuma317 commented Apr 17, 2025

Is your request related to a new offering from AWS?

Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.

  • Yes ✅: please list the AWS provider version which introduced this functionality
    • This functionality is available in the AWS provider. The ability to configure origin access control has been available since AWS provider version 5.94.1.

Is your request related to a problem? Please describe.

Currently, the CloudFront module uses each.key to set the name for origin access control resources. This creates an issue when managing multiple environments (prod, stg, etc.) because origin_access_control names must be unique. With the current implementation, we are forced to use environment names as keys in our configuration, which limits our flexibility in resource naming conventions.

Describe the solution you'd like.

I would like to have the option to configure the origin_access_control name using each.value["name"] instead of being limited to each.key. This would allow us to maintain consistent naming conventions across environments while still ensuring uniqueness. For example, we could use environment-specific keys in our configuration while setting more descriptive names for the actual AWS resources.

Describe alternatives you've considered.

main.tf

resource "aws_cloudfront_origin_access_control" "this" {
  for_each = local.create_origin_access_control ? var.origin_access_control : {}

  name = lookup(each.value, "name", each.key)

  description                       = each.value["description"]
  origin_access_control_origin_type = each.value["origin_type"]
  signing_behavior                  = each.value["signing_behavior"]
  signing_protocol                  = each.value["signing_protocol"]
}

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant