Skip to content

Instantly share code, notes, and snippets.

@mlabieniec
Last active December 5, 2018 20:07
Show Gist options
  • Save mlabieniec/7f0bbba9a744c9c9b53741a2743e0ac7 to your computer and use it in GitHub Desktop.
Save mlabieniec/7f0bbba9a744c9c9b53741a2743e0ac7 to your computer and use it in GitHub Desktop.
This bash command will delete ALL S3 buckets that do not have versions. This will delete anything public (but also private based on your creds) but will error out on any deployment buckets (used for lambda etc.) Use at your own risk!
#!/bin/bash
aws s3api list-buckets --query 'Buckets[*].[Name]' --output text | xargs -I {} bash -c 'aws s3 rb s3://{} --force'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment