-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
fix: Do not create cors_configuration when variable not provided #114
fix: Do not create cors_configuration when variable not provided #114
Conversation
Adding on top of this, when you propagate this
Into your api gateway, it forces the gateway to start overriding your CORS headers returned from the integrations, which makes this module a hassle to use. |
@@ -16,7 +16,7 @@ resource "aws_apigatewayv2_api" "this" { | |||
body = local.is_http ? var.body : null | |||
|
|||
dynamic "cors_configuration" { | |||
for_each = local.is_http && length(var.cors_configuration) > 0 ? [var.cors_configuration] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a valid change
@@ -27,7 +27,7 @@ variable "cors_configuration" { | |||
allow_headers = optional(list(string)) | |||
allow_methods = optional(list(string)) | |||
allow_origins = optional(list(string)) | |||
expose_headers = optional(list(string), []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be a valid change - will test it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not valid - updated in b7ec703
## [5.1.1](v5.1.0...v5.1.1) (2024-08-02) ### Bug Fixes * Do not create cors_configuration when variable not provided ([#114](#114)) ([0ed8ffe](0ed8ffe))
This PR is included in version 5.1.1 🎉 |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
Filters out
null
values when checking forvar.cors_configuration
content and deletes default value forvar.cors_configuration.expose_headers
, which is not required.Motivation and Context
When
var.cors_configuration
is not passed to the module, its content is not{}
, because a type is specified for the variable:this causes condition for the dynamic block to be evaluted incorrectly:
and adds an empty cors_configuration section to the resource:
instead this section should not be configured:
Breaking Changes
Yes.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request