Skip to content

Already exists in stack

0

Hi ,

As i tried to run the below stack using cloudformation its throwing error as ronaldo001 already exists in stack arn:aws:cloudformation(is it issue with stack or bucket name)

stack:

AWSTemplateFormatVersion: '2010-09-09' Resources: S3Bucket: Type: 'AWS::S3::Bucket' Properties: BucketName: 'ronaldo001' # Replace with your bucket name VersioningConfiguration: Status: Enabled Tags: - Key: 'Name' Value: 'ronaldo001' # Replace with your bucket name tag

DevFolder: Type: 'AWS::S3::Bucket' Properties: BucketName: !Ref S3Bucket Tags: - Key: 'Folder' Value: 'dev/'

DevMgsAllReadonlyPdf: Type: 'AWS::S3::Bucket' Properties: BucketName: !Ref S3Bucket Tags: - Key: 'File' Value: 'dev/myreport.pdf'

Outputs: S3BucketName: Description: 'Name of the S3 bucket' Value: !Ref S3Bucket

asked 2 years ago867 views
1 Answer
0

Hello.

S3 bucket names must be publicly unique, so if the bucket name "ronaldo001" is used in another AWS account, you will need to use a different bucket name.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html

A bucket name cannot be used by another AWS account in the same partition until the bucket is deleted.

If changing the bucket name to something else does not resolve the error, could you please copy and paste the exact error message and share it with me?

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
  • By the way, in the following part of the CFn template, the bucket name is obtained with "!Ref S3Bucket", but with this, the name "ronaldo001" is set, so you need to set another random bucket name.

      DevFolder: 
        Type: 'AWS::S3::Bucket' 
        Properties: 
          BucketName: !Ref S3Bucket 
          Tags: 
            - Key: 'Folder' 
              Value: 'dev/'
    
      DevMgsAllReadonlyPdf: 
        Type: 'AWS::S3::Bucket' 
        Properties: 
          BucketName: !Ref S3Bucket 
          Tags: 
            - Key: 'File' 
              Value: 'dev/myreport.pdf'
    
  • Hi Riku, I tried with different bucket name but then to same error

    2024-06-26 20:24:56 UTC+0530 DevMgsAllReadonlyPdf CREATE_FAILED - mrinal009 already exists in stack arn:aws:cloudformation:us-east-1:accountnumber:stack/CATO/fd3177f0-33cb-11ef-a3d0-0ed8c3b51117 2024-06-26 20:24:56 UTC+0530 DevFolder CREATE_FAILED - mrinal009 already exists in stack arn:aws:cloudformation:us-east-1:accountnumber:stack/CATO/fd3177f0-33cb-11ef-a3d0-0ed8c3b51117

  • Give each S3 bucket a different bucket name. "mrinal009" may only be used once. In other words, use a different name for each bucket, as shown below.

      S3Bucket: 
      Type: 'AWS::S3::Bucket' 
      Properties: 
        BucketName: 'ronaldo001' # Replace with your bucket name 
        VersioningConfiguration: 
          Status: Enabled 
          Tags: 
            - Key: 'Name' 
              Value: 'ronaldo001' # Replace with your bucket name tag
    
      DevFolder: 
        Type: 'AWS::S3::Bucket' 
        Properties: 
          BucketName: mrinal009 
          Tags: 
            - Key: 'Folder' 
              Value: 'dev/'
    
      DevMgsAllReadonlyPdf: 
        Type: 'AWS::S3::Bucket' 
        Properties: 
          BucketName: mrinal010 
          Tags: 
            - Key: 'File' 
              Value: 'dev/myreport.pdf'
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.