I have an S3 bucket as a resource in my CloudFormation template, with DeletionPolicy
set to Retain
. This works as expected: when deleting the stack, it does indeed retain the bucket. However, when I attempt to create the stack again, creation fails while attempting to create the same bucket again, with an error message complaining that it already exists.
What do I need to add to my CloudFormation template to make it not try recreating a resource which already exist?
Relevant fragment of my template is as follows:
"Resources": {
"SomeS3Bucket" : {
"Type" : "AWS::S3::Bucket",
"DeletionPolicy" : "Retain",
"Properties": {
"BucketName": "SomeS3Bucket"
}
}