Skip to content
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

FindInMap does not work in AllowOrigins (CorsConfiguration) #1515

Closed
adrai opened this issue Mar 13, 2020 · 5 comments
Closed

FindInMap does not work in AllowOrigins (CorsConfiguration) #1515

adrai opened this issue Mar 13, 2020 · 5 comments
Labels
area/intrinsics Ref, If, Sub, GetAtt, ... type/bug

Comments

@adrai
Copy link

adrai commented Mar 13, 2020

Description: The new feature #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"
          ]
        }
@ShreyaGangishetty
Copy link

@adrai Thank you for reporting this! This will be fixed in #1529 PR

@jfuss jfuss added the area/intrinsics Ref, If, Sub, GetAtt, ... label Nov 23, 2021
@chowson
Copy link

chowson commented Feb 18, 2022

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.

@dannymoscoso
Copy link

might as well call it AllowOrigin as it does not allow multiple origins

@hoffa
Copy link
Contributor

hoffa commented Oct 17, 2022

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 #2533 for more information.

@hoffa
Copy link
Contributor

hoffa commented Nov 3, 2022

Closing in favor of #2533.

@hoffa hoffa closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/intrinsics Ref, If, Sub, GetAtt, ... type/bug
Projects
None yet
Development

No branches or pull requests

7 participants