Description
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"]
}