Created
August 25, 2021 23:16
-
-
Save acg/2b3b396c9556b62ca70754ea11392943 to your computer and use it in GitHub Desktop.
Delete all old version markers in an S3 bucket. Be extremely careful!
This file contains hidden or 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/sh | |
set -e | |
BUCKET="$1" ; shift | |
BATCH_SIZE=100 | |
aws s3api list-object-versions --bucket "$BUCKET" | | |
jq '[.DeleteMarkers[] | {Key, VersionId}]' | | |
jq -c "_nwise($BATCH_SIZE) | {Objects:., Quiet:false}" | | |
tr '\n' '\0' | | |
xargs -0 -n1 aws s3api delete-objects --bucket "$BUCKET" --delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment