- AWS Code Sample demonstrates how to delete an Amazon Glacier archive.

/* Copyright, Inc. or its affiliates. All Rights Reserved. This file is licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.example.glacier; import; import; import; import; public class DeleteArchive { public static void main(String[] args) { final String USAGE = "\n" + "DeleteArchive - deletes an Amazon Glacier archive\n\n" + "Usage: DeleteArchive <vaultName><accountId><archiveId>\n\n" + "Where:\n" + " vaultName - the name of the vault that contains the archive to delete\n\n" + " accountId - the account ID\n\n"+ " archiveId - the archive ID\n\n"; if (args.length < 3) { System.out.println(USAGE); System.exit(1); } String vaultName = args[0]; String accountId = args[1]; String archiveId = args[2]; // Create a GlacierClient object GlacierClient glacier = GlacierClient.builder() .region(Region.US_EAST_1) .build(); deleteGlacierArchive(glacier, vaultName, accountId, archiveId); } public static void deleteGlacierArchive(GlacierClient glacier, String vaultName, String accountId, String archiveId) { try { DeleteArchiveRequest delArcRequest = DeleteArchiveRequest.builder() .vaultName(vaultName) .accountId(accountId) .archiveId(archiveId) .build(); glacier.deleteArchive(delArcRequest); System.out.println("The vault was deleted!"); } catch(GlacierException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }

Sample Details

Service: Amazon Glacier

Last tested: 4/17/2020

Author: scmacdon-aws

Type: full-example