question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-apigatewayv2-alpha): Set route throttling with HttpStage

See original GitHub issue

What 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:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TkinterinShanghaicommented, Apr 30, 2022

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.

1reaction
peterwoodworthcommented, Apr 6, 2022

I hear you @TkinterinShanghai, I’ve created a PR for this feature 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found