s3

last updated: Oct 20, 2023

AWS s3 cli offers no sensible way to delete a bucket if it contains versioned items.

This tiny python script will do the job:

#!/usr/bin/env python
import sys

import boto3

s3 = boto3.resource("s3")
for arg in sys.argv[1:]:
    bucket = s3.Bucket(arg)
    bucket.object_versions.delete()
    bucket.delete()

Save it as rms3bucket and call it

↑ up