I need to delete files stored in a Glacier Vault, but AWS CLI needs the object id and I can't execute the correct command to obtain this id.
Anyone knows the command to see the file id with AWS CLI?
Use aws glacier initiate-job
to obtain an inventory of an Amazon Glacier vault.
From the Amazon Glacier documentation:
The following command initiates a job to get an inventory of the vault my-vault:
aws glacier initiate-job --account-id - --vault-name my-vault --job-parameters '{"Type": "inventory-retrieval"}'
Once the job completes, you can call aws glacier get-job-output
. The inventory will include the archive-id
(files are called archives in Glacier).
Here is a sample output from the get-job-output
documentation:
{"VaultARN":"arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault","InventoryDate":"2015-04-07T00:26:18Z","ArchiveList":[{"ArchiveId":"kKB7ymWJVpPSwhGP6ycSOAekp9ZYe_--zM_mw6k76ZFGEIWQX-ybtRDvc2VkPSDtfKmQrj0IRQLSGsNuDp-AJVlu2ccmDSyDUmZwKbwbpAdGATGDiB3hHO0bjbGehXTcApVud_wyDw","ArchiveDescription":"multipart upload test","CreationDate":"2015-04-06T22:24:34Z","Size":3145728,"SHA256TreeHash":"9628195fcdbcbbe76cdde932d4646fa7de5f219fb39823836d81f0cc0e18aa67"}]}
This's ok
aws glacier initiate-job --account-id - --vault-name my-vault --job-parameters "{ \"Type\": \"inventory-retrieval\" }"
One problem is that how the strings are quoted depending on whether you are using Linux or Mac or Powershell or Windows. See AWS doc on quoting strings
For the Windows command prompt, this works:
aws glacier initiate-job --account-id 123456789012 --vault-name myvault --job-parameters "{\"Type\": \"inventory-retrieval\"}"
For PowerShell use single quotes around the JSON but still escape the double quotes. With Linux and Mac you shouldn't need to escape the double quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With