You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears to be impossible to add multiple API keys to a usage plan in the API Gateway module. Adding a single key works fine, but there is a construct naming conflict when adding multiple keys.
Reproduction Steps
// const api: apigateway.RestApi = new RestApi()....;constplan=api.addUsagePlan('DefaultUsagePlan',{description: `Default usage plan for ${api.node.id}`,name: 'DefaultUsagePlan'});plan.addApiKey(api.addApiKey('ClientKey'));plan.addApiKey(api.addApiKey('TestingKey'));
Error Log
When adding a second API key, I get an error complaining about the reuse of a construct name in CDK.
There is already a Construct with name 'UsagePlanKeyResource' in UsagePlan [DefaultUsagePlan]
.../infrastructure/node_modules/@aws-cdk/core/lib/construct.ts:48
throw new Error(`Validation failed with the following errors:\n ${errorList}`);
^
Error: Validation failed with the following errors:
[LambdaStack/BotAudioVideoApi] The REST API doesn't contain any methods
at Function.synth (.../infrastructure/node_modules/@aws-cdk/core/lib/construct.ts:48:15)
at App.synth (.../infrastructure/node_modules/@aws-cdk/core/lib/app.ts:142:36)
at process.App.process.once (.../infrastructure/node_modules/@aws-cdk/core/lib/app.ts:121:45)
at Object.onceWrapper (events.js:286:20)
at process.emit (events.js:198:13)
at process.EventEmitter.emit (domain.js:448:20)
at process.emit (.../infrastructure/node_modules/source-map-support/source-map-support.js:465:21)
at process.topLevelDomainCallback (domain.js:126:23)
Environment
CLI Version : 1.12.0, 1.15.0
Framework Version: 1.12.0, 1.15.0
OS : MacOS
Language : Typescript
Other
I initially tried this using CDK v1.12.0. I have reproduced it in CDK v1.15.0.
* fix(apigateway): allow multiple api keys to the same usage plan
fixes#4860
* Updated to not change physical ids on existing UsagePlanKey
* Changed to use uniqueId
It appears to be impossible to add multiple API keys to a usage plan in the API Gateway module. Adding a single key works fine, but there is a construct naming conflict when adding multiple keys.
Reproduction Steps
Error Log
When adding a second API key, I get an error complaining about the reuse of a construct name in CDK.
Environment
Other
I initially tried this using CDK v1.12.0. I have reproduced it in CDK v1.15.0.
There is a work-around using
CfnUsagePlanKey
:This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: