feat(apigatewayv2): support for setting routeSelectionExpression for an HTTP API#31373
Conversation
routeSelectionExpressionrouteSelectionExpression for an HTTP API
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
dba7fc4 to
9fd9bad
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
go-to-k
left a comment
There was a problem hiding this comment.
Thanks for this PR! I left some minor comments.
| corsConfiguration, | ||
| description: props?.description, | ||
| disableExecuteApiEndpoint: this.disableExecuteApiEndpoint, | ||
| routeSelectionExpression: props?.routeSelectionExpression === true ? '$request.method $request.path' : undefined, |
There was a problem hiding this comment.
Why $request.method $request.path and not ${request.method} ${request.path}?
It is probably correct as the deployment has not failed. However, the CFn documentation also says it in brackets, and the selection expression guide says the following.
To use multiple variables in a selection expression, enclose the variable in brackets. For example, ${request.path.name} ${request.path.id}.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html
There was a problem hiding this comment.
This is my mistakes! Thank you for your confirmation!!
| The `routeSelectionExpression` option can be configured. | ||
| In the HTTP API, only the value `$request.method $request.path` is allowed, and it can be configured by enabling `routeSelectionExpression`. |
There was a problem hiding this comment.
There is a bit of redundancy in the first and second halves, could you simplify it a bit?
| }); | ||
| }); | ||
|
|
||
| test('routeSelectionExpression is enabled', () => { |
There was a problem hiding this comment.
Additionally, it might be good to write a test for RouteSelectionExpression: Match.absent() when routeSelectionExpression is undefined (or false too?), as a test for the ternary operator, just in case.
Co-authored-by: Kenta Goto (k.goto) <24818752+go-to-k@users.noreply.github.com>
|
@go-to-k Thank you for your review! I've addressed your comments. |
|
@badmintoncryer Could you update snapshots? |
|
@go-to-k Thanks to your notification. I've updated a snapshot. |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #31104.
Reason for this change
Cloudformation supports for configuring
routeSelectionExpressionbut AWS CDK doesn't support this.Description of changes
Added
routeSelectionExpressionprop toHttpApiProps.For HTTP API,
routeSelectionExpressionmust be${request.method} ${request.path}. Therefore, I definedrouteSelectionExpressionas boolean and set it to${request.method} ${request.path}.Description of how you validated changes
Added unit and integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license