Resource handler returned message: "<resourceName> already exists

0

I am trying to create a s3 bucket using CFT but its giving error as Resource handler returned message: "testbucket123 already exists

I have verified there is no such active bucket.

Thank you in advance!!

demandé il y a 4 mois631 vues
2 réponses
1

Hello.

An S3 bucket cannot be created unless it has a public and unique bucket name.
Therefore, if a user with another AWS account is creating an S3 bucket with the same name, you will not be able to create it.
Try creating it with a different S3 bucket name.
https://repost.aws/knowledge-center/s3-error-bucket-already-exists

These error messages indicate that another AWS account owns a bucket with the same name. If you get any of these errors, then you must use a different bucket name to create the bucket.

If you get the Bucket name is already owned by you or BucketAlreadyOwnedByYou error, then check your account for a bucket with the same name. These errors indicate that your account already uses the bucket name. You can use the Amazon S3 console to review existing buckets. Or, you can run the head-bucket AWS CLI command to confirm that you already have a bucket with that name.

profile picture
EXPERT
répondu il y a 4 mois
profile pictureAWS
EXPERT
vérifié il y a 4 mois
1

Moreover, you may need to either randomise bucket name creation:

BucketWithSemiRandomName:
  Type: "AWS::S3::Bucket"
  Properties:
    BucketName: !Join
      - "-"
      - - "bucket-with-semi-random-name"
        - !Select
          - 0
          - !Split
            - "-"
            - !Select
              - 2
              - !Split
                - "/"
                - !Ref "AWS::StackId"

Or just hardcode/parametrize the bucket name with a global name, so that next time you run the IaC it won’t try to recreate it. You can do this by setting the retain property and use the import command: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html

profile picture
EXPERT
répondu il y a 4 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions