This page is only for existing customers of the S3 Glacier service using Vaults and the original REST API from 2012.
If you're looking for archival storage solutions we suggest using the S3 Glacier storage classes in Amazon S3, S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive. To learn more about these storage options, see S3 Glacier storage classes
Deleting a Vault in Amazon S3 Glacier Using the Amazon Command Line Interface
You can delete empty and nonempty vaults in Amazon S3 Glacier (S3 Glacier) using the Amazon Command Line Interface (Amazon CLI).
Topics
(Prerequisite) Setting Up the Amazon CLI
-
Download and configure the Amazon CLI. For instructions, see the following topics in the Amazon Command Line Interface User Guide:
-
Verify your Amazon CLI setup by entering the following commands at the command prompt. These commands don't provide credentials explicitly, so the credentials of the default profile are used.
-
Try using the help command.
aws help
-
To get a list of S3 Glacier vaults on the configured account, use the
list-vaults
command. Replace123456789012
with your Amazon Web Services account ID.aws glacier list-vaults --account-id
123456789012
-
To see the current configuration data for the Amazon CLI, use the
aws configure list
command.aws configure list
-
Example: Deleting an Empty Vault Using the Amazon CLI
-
Use the
delete-vault
command to delete a vault that contains no archives.-
aws glacier delete-vault --vault-name
awsexamplevault
--account-id111122223333
-
Example: Deleting a Nonempty Vault Using the Amazon CLI
S3 Glacier deletes a vault only if there are no archives in the vault as of the last inventory it computed, and there have been no writes to the vault since the last inventory. Deleting a nonempty vault is a three-step process: retrieving archive IDs from a vault's inventory report, deleting each archive, and then deleting the vault.
-
Use the
initiate-job
command to start an inventory retrieval job.aws glacier initiate-job --vault-name
awsexamplevault
--account-id111122223333
--job-parameters='{"Type": "inventory-retrieval"}'Expected output:
{ "location": "/
111122223333
/vaults/awsexamplevault
/jobs/*** jobid ***
", "jobId": "*** jobid ***
" } -
Use the
describe-job
command to check status of the previous retrieval job.aws glacier describe-job --vault-name
awsexamplevault
--account-id111122223333
--job-id*** jobid ***
Expected output:
{ "InventoryRetrievalParameters": { "Format": "JSON" }, "VaultARN": "
*** vault arn ***
", "Completed": false, "JobId": "*** jobid ***
", "Action": "InventoryRetrieval", "CreationDate": "*** job creation date ***
", "StatusCode": "InProgress" } -
Wait for the job to complete.
You must wait until the job output is ready for you to download. If you set a notification configuration on the vault or specified an Amazon Simple Notification Service (Amazon SNS) topic when you initiated the job, S3 Glacier sends a message to the topic after it completes the job.
You can set notification configuration for specific events on the vault. For more information, see Configuring Vault Notifications in Amazon S3 Glacier. S3 Glacier sends a message to the specified SNS topic anytime the specific event occurs.
-
When it's complete, use the
get-job-output
command to download the retrieval job to the fileoutput.json
.aws glacier get-job-output --vault-name
awsexamplevault
--account-id111122223333
--job-id*** jobid ***
output.jsonThis command produces a file with the following fields.
{ "VaultARN":"arn:aws:glacier:
region
:111122223333
:vaults/awsexamplevault
", "InventoryDate":"*** job completion date ***
", "ArchiveList":[ {"ArchiveId":"*** archiveid ***
", "ArchiveDescription":*** archive description (if set) ***, "CreationDate":"*** archive creation date ***
", "Size":"*** archive size (in bytes) ***
", "SHA256TreeHash":"*** archive hash ***
" } {"ArchiveId": ... ]} -
Use the
delete-archive
command to delete each archive from a vault until none remain.aws glacier delete-archive --vault-name
awsexamplevault
--account-id111122223333
--archive-id="*** archiveid ***
"Note
If your Archive ID starts with a hyphen or another special character you will need to put it in quotes in order to run this command.
-
Use the
initiate-job
command to start a new inventory retrieval job.aws glacier initiate-job --vault-name
awsexamplevault
--account-id111122223333
--job-parameters='{"Type": "inventory-retrieval"}' -
When it's complete, use the
delete-vault
command to delete a vault with no archives.aws glacier delete-vault --vault-name
awsexamplevault
--account-id111122223333