Description
Describe the bug
Upon attempting to use the UsagePlan construct, it appears that the apiStages
property is meant to be fully populated at deploy time. We have a use-case where we are deploying a UsagePlan and are having other microservices add their API stages/API Keys to the usage plan via the AWS SDK.
Upon re-deploying the UsagePlan, it appears to be resetting the state of the added API stages and clearing them out entirely. The API keys added are kept intact, but it appears that the API stages are fully managed by the CDK with no option to keep them intact as well similar to how the API keys are managed as part of a Usage Plan. Deployments where the logical id remains the same encounter this issue still (adding a new Tags
key:value pair will reset the state of these added API stages).
There does not appear to be a way to maintain the state of these API stages that are added as part of a different process.
I looked into using the lower-level CfnUsagePlan construct, but did not see a way to accomplish this either. I am open to using this construct as well if there exists a way to do this.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
The current added apiStages on the UsagePlan to be kept intact in the AWS deployed UsagePlan (or an option for this)
Current Behavior
All added API stages were removed (unexpected - unfortunate)
All added API keys stay intact (expected - good)
Reproduction Steps
Initial Deployment:
const plan = new UsagePlan(someScope, 'some-value', {
name: 'some-name',
quota: {
limit: 1000,
period: Period.DAY
},
throttle: {
rateLimit: 10,
burstLimit: 2
}
});
- Manually add API Stages to the UsagePlan
Second Deployment:
const plan = new UsagePlan(someScope, 'some-value', {
name: 'some-name',
quota: {
limit: 1000,
period: Period.DAY
},
throttle: {
rateLimit: 10,
burstLimit: 2
}
});
Tags.of(plan).add('testAddedKey, 'testAddedValue');
- Watch as the API Stages are removed from the UsagePlan (no logical id change, apiStages solely maintained by CDK State)
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.161.0 (build be5ad8b)
Framework Version
No response
Node.js Version
v20.9.0
OS
MacOS Sonoma 14.7.2
Language
TypeScript
Language Version
No response
Other information
No response