My code snippets

With awscli you can access your aws account and manage everything from there. I needed to remove all buckets from S3 so I did this:

aws s3 ls | cut -d " " -f 3 | xargs -I{} aws s3 rm s3://{} --dryrun --recursive

Let’s break it down:

In this case, notice I added the flag --dryrun so we can test it knowing it will do exactly what we want before executing it.

After deleting all objects in the buckets, let’s delete the buckets!

aws s3 ls | cut -d " " -f 3 | xargs -I{} aws s3 rb s3://{}

Boom! Done!