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

fix(apigatewayv2): error while configuring ANY as an allowed method in CORS #13313

Merged
merged 3 commits into from
Mar 22, 2021

Conversation

robertd
Copy link
Contributor

@robertd robertd commented Feb 28, 2021

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

@gitpod-io
Copy link

gitpod-io bot commented Feb 28, 2021

@github-actions github-actions bot added the @aws-cdk/aws-apigatewayv2 Related to Amazon API Gateway v2 label Feb 28, 2021
@robertd
Copy link
Contributor Author

robertd commented Mar 4, 2021

@nija-at Please review when you get a moment. Thanks!

Edit: From OP

I would suggest to either create a separate enum for HTTP methods that aligns with what API gateway expects, or to internally map "ANY" to "*" during synthesis. It's wrong to claim that allowMethods accepts an array of HttpMethod when in fact not all possible values would be correct.

@nija-at I've decided to go with separate enum option because implementation looks much cleaner/clearer than monkey-patching it on the fly. Although, I do wish there was a proper enum extending feature in TypeScript. This solution would look even more elegant 😄.

Let me know what you think.

@nija-at
Copy link
Contributor

nija-at commented Mar 17, 2021

Hello -

Sorry about the delay in reviewing PRs. We are experiencing an increased backlog of items that need our attention.
We will get to your PR as soon as we are able to. Apologies for the delay.

@robertd
Copy link
Contributor Author

robertd commented Mar 17, 2021

Hello -

Sorry about the delay in reviewing PRs. We are experiencing an increased backlog of items that need our attention.
We will get to your PR as soon as we are able to. Apologies for the delay.

No worries. Thanks for letting me know.

@nija-at nija-at changed the title fix(apigatewayv2): switch corsPreflight to use new CorsHttpMethod enum to support '*' as a valid HTTP method fix(apigatewayv2): error while configuring ANY as an allowed method in CORS Mar 22, 2021
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good to me.

I've fixed up the title and the 'BREAKING CHANGE' clause to more closely align with how we usually announce it.

Can you update the commit description (above the breaking changes clause and 'closes' statements)? This will go into the description of the 'git commit', so use the appropriate language.

Usually, the description should answer the two questions - 'Why is this change necessary?', 'How does this commit address the issue?'

@mergify mergify bot dismissed nija-at’s stale review March 22, 2021 14:51

Pull request has been modified.

@robertd
Copy link
Contributor Author

robertd commented Mar 22, 2021

@nija-at Done. Let me know if there is anything else I need to do. Thanks!

@robertd robertd force-pushed the robertd/apigatewayv2-allow-methods branch from db86b4c to 8916f13 Compare March 22, 2021 15:41
@robertd
Copy link
Contributor Author

robertd commented Mar 22, 2021

I've updated and force-pushed git commit title too.

@mergify
Copy link
Contributor

mergify bot commented Mar 22, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Mar 22, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 4404171
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Mar 22, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 34bb338 into aws:master Mar 22, 2021
@robertd robertd deleted the robertd/apigatewayv2-allow-methods branch March 22, 2021 17:23
nija-at pushed a commit that referenced this pull request 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 pull request 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 pull request 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
Projects
None yet
3 participants