Skip to content

Instantly share code, notes, and snippets.

@corkupine
Created September 8, 2023 18:10
Show Gist options
  • Save corkupine/5097ac428ab15ee506adb13cc647e4f7 to your computer and use it in GitHub Desktop.
Save corkupine/5097ac428ab15ee506adb13cc647e4f7 to your computer and use it in GitHub Desktop.
# This doesn't work well with paging in CLI v2 - do this too:
# export AWS_PAGER=""
BUCKET_NAME=argocdexport
OBJECT_KEY=export.yaml
versions=$(aws s3api list-object-versions --bucket $BUCKET_NAME --prefix $OBJECT_KEY | jq -r '.Versions[].VersionId')
count=`echo $versions |jq 'length'`-1
echo "Retrieved $count versions"
for version in $versions
do
echo "Deleting $version..."
aws s3api delete-object --bucket $BUCKET_NAME --key $OBJECT_KEY --version-id $version
echo "Deleted $version"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment