-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
cloudfront custom_header fails on multiple defs - docs say multiple OK. #9944
Comments
Hi Tim, origin {
...
custom_header {
name = "X-CF-Masscache-Host"
value = "${var.spo_env}-masscache-ext.qa.sp.com"
}
custom_header {
name = "X-CF-Pesto-Host"
value = "${var.spo_env}-pesto-ext.qa.sp.com"
}
custom_header {
name = "X-CF-Location-Replacement-String"
value = "${var.spo_env}"
}
} |
Using provider version 3.5 throws an error when using the following syntax
The following syntax will validate and plan correctly, but will not allow multiple
Perhaps the issue is with the type definition. Should the following be |
Hey y'all 👋 Thank you for taking the time to file this issue and for the additional discussion! Given that there's been a number of AWS provider releases since this was initially filed, can anyone confirm whether you're still experiencing this behavior? |
@justinretzolk Hi!
and it throws:
It works if I define it as a block instead:
I am using Terraform version 4.4.0 |
Hey @mariussofron 👋 Notably (and perhaps this is something that's important for the original issue), this resource is not configured to use Attributes as blocks, so I believe the correct syntax would actually be what was mentioned above: custom_header {
name = "name0"
value = "value0"
}
custom_header {
name = "name1"
value = "value1"
} This has been mentioned above, and it was mentioned that this syntax didn't work in version 3.5 of the provider, so there's a chance this will not work. In that case, I'd like to mark this as a bug, as that is how I'd expect this resource to behave. |
I will need to check if any of our envs are on 3.5 but I can confirm you can set multiple Here are some snippets from our internal module where I know we do support setting multiple headers: # static or dynamically generated inputs
custom_origin_headers = [
{
"name": "X-Some-Header-Name",
"value": "SOME_HEADER_VALUE"
}
]
# in a resource or module declaration
resource "aws_cloudfront_distribution" "this" {
# ... stuff
origin {
# ... stuff
dynamic "custom_header" {
for_each = var.custom_origin_headers
content {
name = custom_header.value.name
value = custom_header.value.value
}
}
} |
I'm running aws provider version 3.76.1 and am seeing these errors when I try to modularize my code. As @majormoses states above, a dynamic
|
Community Note
Terraform Version
Terraform v0.12.7
Affected Resource(s)
aws_cloudfront_distribution
Terraform Configuration Files
Debug Output
terraform validate:
Error: Attribute redefined
on main.tf line 28, in resource "aws_cloudfront_distribution" "primary":
28: custom_header = { name = "X-CF-Pesto-Host"
The argument "custom_header" was already set at main.tf:25,5-18. Each argument
may be set only once.
Expected Behavior
Multiple Headers defined (docs say multiple is OK)
From the Docs:
custom_header (Optional) - One or more sub-resources with name and value parameters that specify header data that will be sent to the origin (multiples allowed).
Actual Behavior
Error that custom_header is already defined
Steps to Reproduce
terraform validate
The text was updated successfully, but these errors were encountered: