Skip to content

Instantly share code, notes, and snippets.

@pshirshov
Created December 28, 2022 18:13
Show Gist options
  • Save pshirshov/d6b1c7801aaf00320dc8a3f57c79f327 to your computer and use it in GitHub Desktop.
Save pshirshov/d6b1c7801aaf00320dc8a3f57c79f327 to your computer and use it in GitHub Desktop.
s3 mass bucket removal
#!/usr/bin/env bash
set -x
set -e
PREFIX=$1
buckets=$(aws s3api list-buckets | jq -r '.Buckets | map(.Name) | .[] | select(. | startswith("'${PREFIX}'-"))')
for bucket in $buckets; do
aws s3 rb s3://$bucket --force
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment