Created
July 5, 2025 01:57
-
-
Save dinnouti/85c3c3e122988f3b074be12e32fef309 to your computer and use it in GitHub Desktop.
Delete non-empty Glacier using the inventory-retrieval
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/bash | |
# https://docs.aws.amazon.com/amazonglacier/latest/dev/deleting-vaults-cli.html | |
usage="Usage ${0} account-id vault-name get-job-output.json aws-profile" | |
if [[ -z ${1} ]]; then | |
echo "Missing the account-id" | |
echo ${usage} | |
exit 1 | |
fi | |
if [[ -z ${2} ]]; then | |
echo "Missing the vault name" | |
echo ${usage} | |
exit 1 | |
fi | |
if [[ -z ${3} ]]; then | |
echo "Missing the get-job-output json file" | |
echo ${usage} | |
exit 1 | |
fi | |
account_id=$1 | |
vault_name=$2 | |
file=$3 | |
profile=${4:-'default'} | |
archive_ids=$(jq .ArchiveList[].ArchiveId < $file) | |
for archive_id in ${archive_ids}; do | |
echo "Deleting Archive: ${archive_id}" | |
aws glacier delete-archive --account-id ${account_id} --vault-name ${vault_name} --profile ${profile} --archive-id ${archive_id} | |
done | |
echo "Finished deleting archives" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment