-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(apigatewayv2): support for setting routeSelectionExpression
for an HTTP API
#31373
feat(apigatewayv2): support for setting routeSelectionExpression
for an HTTP API
#31373
Conversation
routeSelectionExpression
routeSelectionExpression
for an HTTP API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! I left some minor comments.
@@ -434,6 +443,7 @@ export class HttpApi extends HttpApiBase { | |||
corsConfiguration, | |||
description: props?.description, | |||
disableExecuteApiEndpoint: this.disableExecuteApiEndpoint, | |||
routeSelectionExpression: props?.routeSelectionExpression === true ? '$request.method $request.path' : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bit of redundancy in the first and second halves, could you simplify it a bit?
@@ -234,6 +234,19 @@ describe('HttpApi', () => { | |||
}); | |||
}); | |||
|
|||
test('routeSelectionExpression is enabled', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) <[email protected]>
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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
routeSelectionExpression
but AWS CDK doesn't support this.Description of changes
Added
routeSelectionExpression
prop toHttpApiProps
.For HTTP API,
routeSelectionExpression
must be${request.method} ${request.path}
. Therefore, I definedrouteSelectionExpression
as 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