serverless-application-model
serverless-application-model copied to clipboard
FindInMap does not work in AllowOrigins (CorsConfiguration)
Description: The new feature https://github.com/awslabs/serverless-application-model/pull/1381 (cors for http-api) does not resolve FindInMap
Steps to reproduce the issue: this works:
"CorsConfiguration": {
"AllowOrigins": [
"http://localhost:3001"
],
"AllowHeaders": [
"Authorization",
"Content-Type"
],
"AllowMethods": [
"GET",
"HEAD",
"PUT",
"PATCH",
"POST",
"DELETE"
],
"ExposeHeaders": [
"X-Next-Page"
]
}
this not:
"Mappings": {
"EnvMap": {
"dev": {
"origins": [
"http://localhost:3000"
]
}
}
}
...
"CorsConfiguration": {
"AllowOrigins": {
"Fn::FindInMap": [
"EnvMap",
{
"Ref": "Environment"
},
"origins"
]
},
"AllowHeaders": [
"Authorization",
"Content-Type"
],
"AllowMethods": [
"GET",
"HEAD",
"PUT",
"PATCH",
"POST",
"DELETE"
],
"ExposeHeaders": [
"X-Next-Page"
]
}
@adrai Thank you for reporting this! This will be fixed in #1529 PR
I'm still having issues with this not working, I'd like to be able to control the AllowOrigins by environment by retrieving the list of origins from a mapping. It works fine for AllowMethods but not AllowOrigins.
Could you reopen the PR? Thanks.
might as well call it AllowOrigin as it does not allow multiple origins
You might be able to get this to work by adding AWS::LanguageExtensions to Transform as such:
Transform:
- AWS::LanguageExtensions
- AWS::Serverless-2016-10-31
AWS::LanguageExtensions resolves intrinsic functions if the value is known when Transforms are run.
See https://github.com/aws/serverless-application-model/issues/2533 for more information.
Closing in favor of https://github.com/aws/serverless-application-model/issues/2533.