Last active
December 27, 2017 09:05
-
-
Save tsvayer/db3a45796ed1e9c7771fa126a834ef96 to your computer and use it in GitHub Desktop.
delete all archives from aws glacier vault (fish function)
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
| # 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