Skip to content

Instantly share code, notes, and snippets.

@tsvayer
Last active December 27, 2017 09:05
Show Gist options
  • Select an option

  • Save tsvayer/db3a45796ed1e9c7771fa126a834ef96 to your computer and use it in GitHub Desktop.

Select an option

Save tsvayer/db3a45796ed1e9c7771fa126a834ef96 to your computer and use it in GitHub Desktop.
delete all archives from aws glacier vault (fish function)
# put it under ~/.config/fish/functions
function delete_archives_from_aws_glacier_vault -a ACCID VAULT
set JOBID ( \
aws glacier initiate-job \
--account-id $ACCID \
--vault-name $VAULT \
--job-parameters '{"Type": "inventory-retrieval"}' \
| jq -r '.jobId' \
)
#TODO: wait for job completion
aws glacier get-job-output \
--account-id $ACCID \
--vault-name $VAULT \
--job-id $JOBID \
./job.json
jq -r '.ArchiveList[].ArchiveId' ./job.json \
| while read ARCHID
aws glacier delete-archive \
--account-id $ACCID \
--vault-name $VAULT \
--archive-id="$ARCHID"
echo $ARCHID
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment