Follow these steps to clear all archives from an AWS glacier vault. After this is finished, you will be able to delete the vault itself through the browser console.
This will create a job that collects required information about the vault.
aws glacier initiate-job --job-parameters '{"Type": "inventory-retrieval"}' --account-id YOUR_ACCOUNT_ID --region YOUR_REGION --vault-name YOUR_VAULT_NAMEThis can take hours or even days, depending on the size of the vault. Use the following command to check if it is ready:
aws glacier list-jobs --account-id YOUR_ACCOUNT_ID --region YOUR_REGION --vault-name YOUR_VAULT_NAMECopy the JobId (including the quotes) for the next step.
If you do not want to check your job status continously, you can create a notification to receive a email when your job is finished. Configuring Vault Notifications Using the AWS Command Line Interface
aws glacier set-vault-notifications --account-id YOUR_ACCOUNT_ID --vault-name YOUR_VAULT_NAME --vault-notification-config ~/notificationconfig.jsonOr you enable it via the aws console: Configuring Vault Notifications by Using the S3 Glacier Console
The following command will result in a file listing all archive IDs, required for step 3.
aws glacier get-job-output --account-id YOUR_ACCOUNT_ID --region YOUR_REGION --vault-name YOUR_VAULT_NAME --job-id YOUR_JOB_ID ./job-output.jsonSet the following parameters through environment variables:
export AWS_ACCOUNT_ID=YOUR_ACCOUNT_ID
export AWS_VAULT_NAME=YOUR_VAULT_NAMEAnd run the script via npx/pnpx:
npx @chieforz/clear-aws-glacier ./job-output.json
pnpx @chieforz/clear-aws-glacier ./job-output.jsonAll additional parameters will be passed to the aws cli sdk: Command line options
For debugging you can pass --verbose to disable the progress bar.
This tutorial is based on: https://gist.github.com/Remiii/507f500b5c4e801e4ddc icon