Skip to content

How to attach an existing usage plan to an api gateway using CDK #22588

Closed

Description

@affanc

Describe the feature

How to attach an existing usage plan to an api gateway using CDK

Use Case

Cx wants to import existing usagePlan for aws-api-gateway using CDK, but running into this error below:

Resource handler returned message: "Invalid API Stage {api: %s, stage: %s} specified for usageplan %s (Service: ApiGateway, Status Code: 400, Request ID: ...)" (RequestToken: ..., HandlerErrorCode: InvalidRequest)

Proposed Solution

Tried to create new usagePlan from the link here : https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-apigateway.UsagePlan.htmlbut same error occurred. I have included the code snippet

Other Information

const usagePlanEvt = new UsagePlan(this, myUsagePlan, {
            name: myUsagePlan,
            description: `${this.stackEnv} usage plan`,
            throttle: {
                rateLimit: 5,
                burstLimit: 2
            },
            quota: {
                limit: 500,
                period: [Period.DAY ](#),
            }
        });
        const apiKeyNameEvt = `${prefix}-EVT-Api-Key`.toLocaleLowerCase();
        const apiKeyEvt = new ApiKey(this, apiKeyNameEvt, {
            apiKeyName: apiKeyNameEvt,
        });
        usagePlanEvt.addApiKey(apiKeyEvt);

        const api = RestApi.fromRestApiId(this, 'ImportedApi', 'ca69uil4i1');
        usagePlanEvt.addApiStage({
            api: api
        });

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.46.0

Environment details (OS name and version, etc.)

Windows

Activity

  1. added
    feature-requestA feature should be added or improved.
    needs-triageThis issue or PR still needs to be triaged.
    on Oct 20, 2022
  2. changed the title [-](module name): (short issue description)[/-] [+]How to attach an existing usage plan to an api gateway using CDK[/+] on Oct 20, 2022
  3. locked and limited conversation to collaborators on Nov 16, 2022
  4. converted this issue into a discussion #22944 on Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-apigatewayRelated to Amazon API Gatewayfeature-requestA feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions