-
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
(core): Cloudformation Stack refactoring #33333
Comments
Yes, it's awesome to see this feature being announced. Bringing this up to the team for visibility and inputs. Meanwhile, we welcome any inputs and ideas here. |
It would be very much appreciated if the implementation of this allowed for separate plan + apply stages that can be done with different permission sets, similar to how you can currently |
hey guys, I needed this for my commercial project I'm working on, so I put together the dirty solution and found some interesting moments:
The draft PR is linked to this issue – happy to hear community thoughts on this dirty implementation and possible solutions to the points above. ➜ infra git:(main) ✗ npc cdk deploy "Dev/DataPlatformStorage" --profile "..." # deploy any outstanding changes of source stack before refactor
➜ infra git:(main) ✗ npx cdk deploy "Dev/AnotherTmpPlatformStorage" --profile "..." # first deploy the target stack with at least one resource
➜ infra git:(main) ✗ npx cdk refactor --from-stack "Dev/DataPlatformStorage" --to-stack "Dev/AnotherTmpPlatformStorage" --source-resource "AppleRawBucketBB5C0068" --target-resource "AppleRawBucketBB5C0068" --profile "..." |
@otaviomacedo see here for some real life context |
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
RFC is in the works: aws/aws-cdk-rfcs#705 |
Describe the feature
Recently AWS introduced the possibility to refactor Cfn stacks using AWS CLI and having in mind how's hard to refactor CDK stacks and move resources between stacks, I think this feature needs an implementation and integration within the CDk.
https://aws.amazon.com/about-aws/whats-new/2025/02/reshape-aws-cloudformation-stack-refactoring/
Use Case
Refactoring of CDK stacks - moving resources between stacks, renaming them (logical IDs)
Proposed Solution
Thinking aloud:
diff
mechanisms, b) find the newly added resources in other stacks that share the same resource (shallow copy equality(?) since logicalId will be different), c) run the refactor Cfn's API callsStack:_toCloudFormation()
function, we could detect removed resources either by comparing newly generated template or usingdiff
mechanism as above, then creating templates for Cfn'sCreateStackRefactor
API call for deploy stage.Other Information
No response
Acknowledgements
CDK version used
2.178.0
Environment details (OS name and version, etc.)
macOS, node v22
The text was updated successfully, but these errors were encountered: