- Mais recentes
- Mais votos
- Mais comentários
Hi there!
From the notes, I understand that you are getting an error “CloudFormation cannot update a stack when a custom-named resource requires replacing”, while trying to updating an existing stack. Please correct me if I misunderstood.
Please note that this error typically occurs when a stack update tries to replace resources that have properties with custom names. AWS CloudFormation doesn't replace a resource that has a custom name unless that custom name is changed to a different name. I understand that in your case, you have been naming everything with the project's prefix and stage. Nonetheless, you can still use that method with slight changes.
This is how you can resolve the issue:
- In a code editor, open the AWS CloudFormation template for the stack that you want to update.
- Replace the names, or values, of any resource properties that have custom names with different names. You can refer to [1] on naming your resources.
- Save the changes to your AWS CloudFormation template, and then use the template to update your stack, you can check [2] on updating stacks directly.
In your case on step 2, you can change from e.g. projectname-dev to projectname-dev1. Another method is to omit the DBInstanceIdentifier property from your template. However, in this case AWS CloudFormation will generate a unique physical ID to use for the DB instance.
To prevent a stack failure and avoid the error message, change any resources with custom names to use different names before you update a stack.
I hope you find the above information helpful. Have a great day ahead!
References:
[1] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html [2] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-direct.html
Hi Scott
I appreciate the need to adopt a nomenclature standard for resources as that certainly helps with administration. Having worked a lot with nomenclature standards for public cloud resources and implementing them via Terraform, it's regressive to have to change custom resource names before updating CloudFormation stacks. Now, given that AWS uses tags even when naming some resources (e.g. VPC, EC2 instance) by using a tag with Key=Name, I recommend using **tags ** for naming all resources (whether implicitly done for resources such as VPC or needed explicity for resources such as EC2 security groups). Using tags to implement a nomenclature standard for your AWS resources will help you avoid such issues with CloudFormation.
So, for your example, you may omit GroupName from the CloudFormation template (it's not required) and instead use Tags (Name=projectname-dev). When you do this, your security group name will be a combination of your stack name, LogicalID for the resource and a random string, but your tag Name=projectname-dev will be assigned to the security group and may be used for your administration.