Reputation: 14831
I am developing my CloudFormation template. I have an S3 bucket resource in my template with the following code.
StorageBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
BucketName: pathein-directory-storage
AccessControl: PublicRead
As you can see I set the DeletionPolicy to Retain because I want to retain the Bucket and its data when the template is deleted. At some point, I explicitly deleted the template. But my S3 bucket was not deleted.
Now, I am trying to deploy my template again. But the deployment is failing because the bucket already exists with the same name. How can I figure my template to use the existing bucket if there is already one?
Upvotes: 2
Views: 1730
Reputation: 238737
How can I figure my template to use the existing bucket if there is already one?
You have to import it into CFN as shown in:
Luckily, AWS::S3::Bucket
is one of the resources that are supported for the import operation.
You begin the procedure in the console when you Create stack with existing resources
:
Upvotes: 1