Created
January 14, 2020 17:25
-
-
Save eksiscloud/28ce84b914d3a37ca58dd67031f5786a to your computer and use it in GitHub Desktop.
How to delete AWS S3 Glacier vault
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
1. aws glacier initiate-job --job-parameters '{"Type": "inventory-retrieval"}' --vault-name YOUR_VAULT_NAME --account-id YOUR_ACCOUNT_ID --region YOUR_REGION | |
2. aws glacier list-jobs --vault-name YOUR_VAULT_NAME --region YOUR_REGION --account-id YOUR_ACCOUNT_ID | |
try again and again until you get "Completed": true, and "StatusCode": "Succeeded" | |
it can take several hours or days | |
3. aws glacier get-job-output --job-id YOUR_JOB_ID --vault-name YOUR_VAULT_NAME --region YOUR_REGION --account-id YOUR_ACCOUNT_ID ./output.json | |
copy job_id from the output of the second step | |
4. nano glacier.php | |
<?php | |
$file = './output.json' ; | |
$accountId = 'YOUR_ACCOUNT_ID' ; | |
$region = 'YOUR_REGION' ; | |
$vaultName = 'YOUR_VAULT_NAME' ; | |
$string = file_get_contents ( $file ) ; | |
$json = json_decode($string, true ) ; | |
foreach ( $json [ 'ArchiveList' ] as $jsonArchives ) | |
{ | |
echo 'Delete Archive: ' . $jsonArchives [ 'ArchiveId' ] . "\n" ; | |
exec ( 'aws glacier delete-archive --archive-id="' . $jsonArchives [ 'ArchiveId' ] . '" --vault-name ' . $vaultName . ' --account-id ' . $accountId . ' --region ' . $region , $output ) ; | |
echo $output ; | |
} | |
5. aws glacier delete-vault --vault-name YOUR_VAULT_NAME --account-id YOUR_ACCOUNT_ID --region YOUR_REGION | |
##Job done and the vault is deleted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Done for linking purposes.
The original is here: https://gist.github.com/Remiii/507f500b5c4e801e4ddc