Closed rajinder-yadav closed 4 years ago
hey @rajinder-yadav
CloudFormation does not delete S3 buckets that are non-empty.
You can only delete empty buckets. Deletion fails for buckets that have contents.
Here's the relevant documentation.
The bucket is empty, still not being destroyed.
The bucket is empty, still not being destroyed.
@shivlaks
@rajinder-yadav oh I see that you're using the aws-s3
module. The buckets are created with a default retention policy of Retain
you can set this with the removalPolicy
property:
const bucket = new s3.Bucket(this, 'MyBucket', {
versioned: true,
removalPolicy: cdk.RemovalPolicy.DESTROY
});
@shivlaks that worked for me, can you please have the "Getting Started" document updated so it won't confuse new Users.
We should probably set the removal policy in the Getting Started.
I've added this to the CDK Dev Guide repo. https://github.com/awsdocs/aws-cdk-guide/issues/159
Should get to it soon... I'll close this one.
Follow CDK Hello world here: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html
When I did the "cdk destroy" my S3 bucket was not deleted. I tried again with same result.
Environment