-
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
(aws-apigatewayv2-alpha): Set route throttling with HttpStage #19626
Comments
Hey @TkinterinShanghai, The UsagePlan option is available in the apigateway package and not v2 because CloudFormation makes the distinction between v1 and v2 here. CloudFormation has a UsagePlan resource for v1, and no such resource for V2. So there's not much we can do here |
I'm not too familiar with these services, but I believe there is no usage plan construct because the functionality lies somewhere else in v2, see here. If you still believe there should be a UsagePlan construct for CloudFormation, then I recommend opening an issue with the CloudFormation coverage roadmap |
I just don't see the Option to add a Usage Plan/Throttling at all. I'd be happy with any way of doing this as long as it's feasible. I think adding a method to the Api, the Stage or having a Construct by itself would all be intuitive ways of implementing this. If adding throttling to the Http Api Gateway is possible via the website, I would expect Cdk v2 to also be able to handle that. I still haven't found that option. Maybe it's just well hidden and I'm not aware it exists |
The CDK is limited by CloudFormation - so we can only work with what they offer us. Looking at their docs, we set throttling in In the meantime, you can access the underlying CloudFormation Stage resource with escape hatches You'll want to do something like this before we directly support throttling: const stage = new apigwv2-alpha.HttpStage(...);
const cfnStage = stage.node.defaultChild as apigwv2.CfnStage;
cfnStage.addPropertyOverride('RouteSettings', ...); But, like I said before, no UsagePlan resource exists in Cloudformation's ApiGatewayV2 module, so there's nothing the CDK can do about that. |
Thanks, you put me on the right track. This worked: const cfnStage = api.defaultStage?.node.defaultChild as CfnStage; // api is of type HttpApi
cfnStage.addPropertyOverride("DefaultRouteSettings", {ThrottlingBurstLimit: 1500, ThrottlingRateLimit: 1000}); But it would be nice if this could be incorporated into ApiGatewayV2, as I think it is a somewhat important missing feature and this way of doing it is pretty hacky |
I hear you @TkinterinShanghai, I've created a PR for this feature 🙂 |
fixes #19626 added integ tests let me know if change to readme is necessary ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
fixes #19626 added integ tests let me know if change to readme is necessary ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
fixes aws#19626 added integ tests let me know if change to readme is necessary ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This seems to be a bug elsewhere but creating a stage doesnt work because "Stage already exists", even when setting createDefaultStage to false in the HttpApi class. But this bug affects this fix, because the fix relies on the Stage working. So I think additionally having a method such as createDefaultThrottling on the HttpApi or a setThrottling method on the HttpStage would work even with the current bug. |
What is the problem?
Unlike the module
aws_apigateway
where I would just dothere doesnt seem to be an equivalent way of doing this in
aws-apigatewayv2-alpha
.Reproduction Steps
I created an HTTP Api
and tried to just add throttling in the same scope, hoping that it would automatically apply to the only api gateway specified
What did you expect to happen?
Have a method
.addUsagePlan
on the Http Api class or having a field inprops
that allows me to link theUsagePlan
to the Api.What actually happened?
Throttling was not configured for Api
CDK CLI Version
2.17.0
Framework Version
No response
Node.js Version
16.12
OS
Windows
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: