Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Abort all orphaned multipart upload fragments for a bucket.
#!/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
You can’t perform that action at this time.