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

(aws-apigatewayv2): Specifying HttpMethod.ANY as allowMethod of CORS configuration causes deployment failure. #13643

Closed
acomagu opened this issue Mar 17, 2021 · 4 comments · Fixed by #13313
Assignees
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@acomagu
Copy link
Contributor

acomagu commented Mar 17, 2021

new apigatewayv2.HttpApi(this, 'API', {
  corsPreflight: {
    allowMethods: [apigatewayv2.HttpMethod.ANY],
    allowOrigins: ['*'],
    allowHeaders: ['*'],
    maxAge: cdk.Duration.seconds(600),
  },
});

This generates such template:

"APIXXXXXX": {
  "Type": "AWS::ApiGatewayV2::Api",
  "Properties": {
    "CorsConfiguration": {
      "AllowMethods": [
        "ANY"
      ],
      ...

But deploying this fails with the error: Method ANY is not supported (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; ...)

What did you expect to happen?

What actually happened?

The below is correct CloudFormation template:

"APIXXXXXX": {
  "Type": "AWS::ApiGatewayV2::Api",
  "Properties": {
    "CorsConfiguration": {
      "AllowMethods": [
        "*"
      ],
      ...

So the beginning code should generate such YAML.

Environment

  • CDK CLI Version:2.0.0-alpha.0 (build beadc66)
  • Framework Version: 2.0.0-alpha.0
  • Node.js Version: v15.10.0
  • OS : Linux acm-envy2-win-wsl 5.4.72-microsoft-standard-WSL2 Initial external release #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 GNU/Linux
  • Language (Version): TypeScript 4.2.3

This is 🐛 Bug Report

@acomagu acomagu added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 17, 2021
@github-actions github-actions bot added the @aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 label Mar 17, 2021
@robertd
Copy link
Contributor

robertd commented Mar 17, 2021

@acomagu Should be addressed by #13313.

@acomagu
Copy link
Contributor Author

acomagu commented Mar 17, 2021

Oh sorry, I didn't notice that.

Thank you for great work! ❤️

@nija-at
Copy link
Contributor

nija-at commented Mar 18, 2021

As noted by @robertd, we already have this issue - #13280.

Closing this as a duplicate.

@nija-at nija-at closed this as completed Mar 18, 2021
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

mergify bot pushed a commit that referenced this issue Mar 22, 2021
…n CORS (#13313)

API gateway expects `*` to represent `ANY` HTTP method. `HttpMethod` enum doesn't 
have a value for that, thus causing errors when passing  `HttpMethod` 's `ANY` option.

This commit introduces `CorsHttpMethod` enum which has a proper `ANY` mapping to `*`.

Closes #13280.
Closes #13643.

BREAKING CHANGE: The type of `allowMethods` property under `corsPreflight`
section is changed from `HttpMethod` to `CorsHttpMethod`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
nija-at pushed a commit that referenced this issue Mar 23, 2021
…n CORS (#13313)

API gateway expects `*` to represent `ANY` HTTP method. `HttpMethod` enum doesn't 
have a value for that, thus causing errors when passing  `HttpMethod` 's `ANY` option.

This commit introduces `CorsHttpMethod` enum which has a proper `ANY` mapping to `*`.

Closes #13280.
Closes #13643.

BREAKING CHANGE: The type of `allowMethods` property under `corsPreflight`
section is changed from `HttpMethod` to `CorsHttpMethod`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
eladb pushed a commit that referenced this issue Mar 24, 2021
…n CORS (#13313)

API gateway expects `*` to represent `ANY` HTTP method. `HttpMethod` enum doesn't 
have a value for that, thus causing errors when passing  `HttpMethod` 's `ANY` option.

This commit introduces `CorsHttpMethod` enum which has a proper `ANY` mapping to `*`.

Closes #13280.
Closes #13643.

BREAKING CHANGE: The type of `allowMethods` property under `corsPreflight`
section is changed from `HttpMethod` to `CorsHttpMethod`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…n CORS (aws#13313)

API gateway expects `*` to represent `ANY` HTTP method. `HttpMethod` enum doesn't 
have a value for that, thus causing errors when passing  `HttpMethod` 's `ANY` option.

This commit introduces `CorsHttpMethod` enum which has a proper `ANY` mapping to `*`.

Closes aws#13280.
Closes aws#13643.

BREAKING CHANGE: The type of `allowMethods` property under `corsPreflight`
section is changed from `HttpMethod` to `CorsHttpMethod`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants