Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 2.41 KB

README.md

File metadata and controls

55 lines (42 loc) · 2.41 KB

AWS Glacier: Clear vault

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.

Step 1 / Retrieve inventory

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_NAME

This 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_NAME

Copy the JobId (including the quotes) for the next step.

(Alternative Step / Set Job Notification)

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.json

Or you enable it via the aws console: Configuring Vault Notifications by Using the S3 Glacier Console

Step 2 / Get the ArchivesIds

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.json

Step 3 / Delete archives

Set the following parameters through environment variables:

export AWS_ACCOUNT_ID=YOUR_ACCOUNT_ID
export AWS_VAULT_NAME=YOUR_VAULT_NAME

And run the script via npx/pnpx:

npx @chieforz/clear-aws-glacier ./job-output.json

pnpx @chieforz/clear-aws-glacier ./job-output.json

All additional parameters will be passed to the aws cli sdk: Command line options

For debugging you can pass --verbose to disable the progress bar.

Acknowledgement

This tutorial is based on: https://gist.github.com/Remiii/507f500b5c4e801e4ddc icon