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.
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.
Versioning: It allows you to preserve, retrieve, and restore every version of every object in a bucket. Once enabled, it cannot be suspended, only disabled.
Delete Markers: Once you delete a versioned object in s3, a delete marker is inserted. This marker becomes the current version, simulating a "delete" operatings but not actually removing the object.
We need to delete all versions and delete markers to empty the s3 bucket.