(aws-apigatewayv2-alpha): Set route throttling with HttpStage
See original GitHub issueWhat is the problem?
Unlike the module aws_apigateway
where I would just do
const api = new apigateway.RestApi(this, 'hello-api');
const plan = api.addUsagePlan('UsagePlan', {
name: 'Easy',
throttle: {
rateLimit: 10,
burstLimit: 2
}
});
there doesnt seem to be an equivalent way of doing this in aws-apigatewayv2-alpha
.
Reproduction Steps
I created an HTTP Api
export class APIConstruct extends Construct {
public api: HttpApi;
constructor(scope: Construct, id: idType, authorizer: HttpUserPoolAuthorizer) {
super(scope, id);
const throtting = new UsagePlan(this, "Throttling", {
throttle: { burstLimit: 999, rateLimit: 99 },
});
this.api = new HttpApi(this, id, {
apiName: id,
defaultAuthorizer: authorizer,
});
}
}
and tried to just add throttling in the same scope, hoping that it would automatically apply to the only api gateway specified
const throtting = new UsagePlan(this, "TypiRateLimiting", { throttle: { burstLimit: 999, rateLimit: 99 } });
What did you expect to happen?
Have a method .addUsagePlan
on the Http Api class or having a field in props
that allows me to link the UsagePlan
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
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
aws-cdk/aws-apigatewayv2-alpha module
Use HttpStage to create a Stage resource for HTTP APIs. The following code sets up a Stage, whose URL is available at https://{api_id}.execute-api.{region}....
Read more >aws-cdk/aws-apigatewayv2-integrations-alpha module
Lambda integrations enable integrating an HTTP API route with a Lambda function. When a client invokes the route, the API Gateway service forwards...
Read more >aws-cdk/aws-apigatewayv2-authorizers-alpha module
Access control for Http Apis is managed by restricting which routes can be invoked via. Authorizers and scopes can either be applied to...
Read more >aws-cdk/aws-apigatewayv2-integrations module
The following code configures a route GET /books with a Lambda proxy integration. import { HttpLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations' ...
Read more >class HttpRoute (construct) · AWS CDK
Java, software.amazon.awscdk.services.apigatewayv2.alpha.HttpRoute ... Route class that creates the Route for API Gateway HTTP API.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
I hear you @TkinterinShanghai, I’ve created a PR for this feature 🙂