Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudformation template fails due to S3Bucket resource already exists

I have created an S3 Bucket, with the cloud formation, Lets Say Bucket Name is S3Bucket, I don't want this bucket getting deleted if I delete stack, so added Deletion Policy to Retain,

Now the problem here is, If run the stack again, it complains S3Bucket name already exists. If a bucket already exists, it should not complain. What to do for this. Please help

like image 541
Swathi Avatar asked Sep 16 '25 20:09

Swathi


1 Answers

I faced this in the past and what i did in order to resolve this is that i created a common AWS cloudformation template/stack which will create all our common resources which are static(Handle it like a bootstrap template). Usually i am adding in this template the creation of s3 buckets,VPC, networking, databases creation, etc.

Then you can create other AWS cloudformation templates/stacks for your rest resources which are dynamic and changing usually like lambdas,ec2, api gateway etc.

like image 196
Xanthos Symeou Avatar answered Sep 19 '25 18:09

Xanthos Symeou