life is too short for a diary




Empty s3 bucket and Delete using Jenkins and AWS CLI

Tags: jenkins aws

Amazon Simple Storage Service (s3) is a scalable object storage service provided by AWS. It allows users to store and retrieve vast amount of data, make it a fundamental building block for many applications hosted on AWS. Deleting a s3 bucket is a two step process: empty a s3 bucket and then delete a s3 bucket.

Deleting bucket without versioning

If a bucket has no versioning, we can empty s3 bucket using aws cli via jenkins

If there's versioning, then it will fail with the following error:

The bucket you tried to delete is not empty. You must delte all versions in the bucket.

Understanding s3 versioning and delete markers

Deleting bucket with versioning

We need to delete all versions and delete markers to empty the s3 bucket.


comments powered by Disqus