-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UsagePlan: No option to preserve added API stages to the usage plan if not included as part of construct instantiation #32544
Comments
Hi @ChaseBowen , thanks for reaching out. AFAIU, construct deployed through CDK will be maintained and reset by CDK even if you make changes outside CDK. In your scenario, what is happening is cdk deploys the construct, then outside changes are made and then CDK identifies the changes and reverts those back as per the syntheised template it had. So I don't think its a flaw in the CDK Process. However CDK provides workaround for such scenario-
I hope this helps in your scenario. Let me know if you have questions. |
Hey @khushail Sorry this may have been more of a feature request. I would like if the API stages were managed similar to how API keys are managed as part of a usage plan in terms of state. There is no I'm not sure that Drift Detection or CDK imports would solve the issue based on:
Ideally, we could construct a new usage plan as such // keeps existing api stages added by any means (sdk or similar)
new UsagePlan(someScope, 'some-value', { retainStages: true, ...} )
plan.addApiKey() // ADDS a new Api Key (not required by us since we wouldn't use this)
plan.addApiStage() // ADDS a new Api Stage (not required by us since we wouldn't use this) |
@ChaseBowen , thanks for clarifcation around your usecase. So you want usagePlan to retain its stages. |
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
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:
Second Deployment:
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
The text was updated successfully, but these errors were encountered: