Already exists in stack arn:aws:cloudformation error causing trouble?
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Let’s take a look at how our Support Team recently helped a customer when they came across “Custom Named Resource already exists in stack” error in AWS CloudFormation?
What is already exists in stack arn:aws:cloudformation error?
If your AWS CloudFormation stack has been failing to create a resource, you have come to the right place. In fact, the “Custom Named Resource already exists in stack” is a common issue. Fortunately, our Support Team has an easy solution for this specific problem.
This error often pops up when you have one or multiple custom-named resources with the same name and the same value. AWS CloudFormation requires each custom-named resource to have a unique Physical ID. Additionally, this cannot be reused for most resources defined in CloudFormation.
However, we can resolve the error by modifying the name of the failing or repeating resource to a unique name. Another option would be to opt-out of defining a custom name for the resource.
When a custom name is not set, AWS CloudFormation automatically generates a unique name during resource creation. This will not conflict with other existing resources.
How to resolve “already exists in stack“ arn:aws:cloudformation error?
First, we have to check whether other resources have the same name as the failed resource in the AWS CloudFormation template where the latter is present.
For instance, in the example below, the stack fails as each IAM ManagedPolicy resource has the same name:
# This stack will fail S3DeletePolicy: Type: AWS::IAM::ManagedPolicy Properties: ManagedPolicyName: Fn::Join: - _ - - FinalS3WritePolicy - Ref: EnvType PolicyDocument: ........ ........ S3WritePolicy: Type: AWS::IAM::ManagedPolicy Properties: ManagedPolicyName: Fn::Join: - _ - - FinalS3WritePolicy - Ref: EnvType PolicyDocument: ........ ........
After that, we will update the name of any resource with a duplicate name. For instance, in the above example, we will modify the first instance of FinalS3WritePolicy to FinalS3DeletePolicy. We can also opt to remove the custom name.
Our Support Team would like to further illustrate this with the following examples. Here Stack A succeeds as each IAM ManagedPolicy resource comes with a unique custom name. Whereas Stack B succeeds as no custom name values are set for either of the ManagedPolicyName properties.
Stack B
# This stack succeeds as unique names are set: S3DeletePolicy: Type: AWS::IAM::ManagedPolicy Properties: ManagedPolicyName: Fn::Join: - _ - - FinalS3DeletePolicy - Ref: EnvType PolicyDocument: ........ ........ S3WritePolicy: Type: AWS::IAM::ManagedPolicy Properties: ManagedPolicyName: Fn::Join: - _ - - FinalS3WritePolicy - Ref: EnvType PolicyDocument: ........ ........
Stack B:
# This stack succeeds as no names are set S3DeletePolicy: Type: AWS::IAM::ManagedPolicy Properties: PolicyDocument: ........ ........ S3WritePolicy: Type: AWS::IAM::ManagedPolicy Properties: PolicyDocument: ........ ........
[Need further assistance with this query? Give us a call.]
Conclusion
To sum up, the skilled Support Engineers at Bobcares demonstrated how to resolve the “Custom Named Resource already exists in stack” error commonly seen in AWS CloudFormation.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments