Skip to content
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

Better way to refactoring stacks (renaming logical ID, stack name?) #684

Open
foriequal0 opened this issue Nov 18, 2020 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@foriequal0
Copy link

foriequal0 commented Nov 18, 2020

I'm sorry but I couldn't find a better place to write this.
I found that refactoring CF stacks is hard. It would be much easier if I can rename logical ID, and stack names.

CDK promised us 'you can build your own abstraction', and it means we need to refactor them. But I can't. I can't move CDK constructs around or even rename them in-place since it'll delete existing resources and recreate it.

There is a manual for refactoring a stack (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/refactor-stacks.html) (it is not easy to remove/replace references to resources to be deleted: #683), but not all resources support import as the manual says, and the operation is not atomic even if luckly all of them supports it. (being able to import a resource into multiple stacks would provide atomicity?)
e.g. @aws-cdk/aws-eks's Cluster relies on AWS::CloudFormation::CustomResource. It doesn't support import.
AWS::EC2::InternetGateway supports it! However, AWS::EC2::VPCGatewayAttachment doesn't. @aws-cdk/aws-eks uses AWS::CloudFormation::CustomResource for creating, managing EKS Cluster (as a workaround of this limitations? aws/aws-cdk#11403), but it doesn't support it too.

I feel like I have limited choices:

  1. Refactor them anyway by sacrificing downtimes, or risking data losses by mistakes.
  2. Bear with old names. It means have to digging abstraction layers, and add a ton of this.renameLogicalId('PublicRouteTableIGWFF92FCC4', 'SmallMistakesOfThePastIGWABCD2134'). (I currently chose this. I hope that someone who will maintain the code is not psychopath who knows where I live)
  3. Don't use CDK, and don't be tempted to refactor them. No one tries to refactor CF stacks.
  4. Apply DeletionPolicy: Retain on all resources and abandon CF.

I wish there is a better way to refactoring stacks.

@deleugpn
Copy link

While we're at it, please for the love of God let us rename Stacks

@foriequal0
Copy link
Author

Since I'm using CDK, I'm using this class to pin resource names. https://gist.github.com/foriequal0/f1f4ea279fb64836e5fb38efefa133d7
It doesn't help you to rename, but at least it help you to refactor resources.

@rnhurt
Copy link

rnhurt commented Feb 3, 2021

cfn-stack-rename is an interesting take on this problem. I haven't used it yet but it looks very promising.

@brianterry brianterry added the enhancement New feature or request label Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants