Created
June 1, 2019 05:58
-
-
Save bfolkens/a8c9f66c60782923d54372af818f543e to your computer and use it in GitHub Desktop.
Abort all orphaned multipart upload fragments for a bucket.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage | |
# ./abort-all-orphaned-multipart-uploads.sh [profile] | |
# | |
# Requirements | |
# jq | |
# awscli | |
profile=$1 | |
aws s3 ls --profile $profile | \ | |
cut -f 3 -d ' ' | \ | |
while read bucket; do | |
echo "Listing upload fragments in $bucket" | |
aws s3api list-multipart-uploads --profile $profile --bucket $bucket | \ | |
jq -r '.Uploads[] | "--key \"\(.Key)\" --upload-id \(.UploadId)"' | while read -r line; do | |
echo " abort-multipart-upload $line" | |
eval "aws s3api abort-multipart-upload --profile $profile --bucket $bucket $line" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment