

 **This page is only for existing customers of the Amazon Glacier service using Vaults and the original REST API from 2012.**

If you're looking for archival storage solutions, we recommend using the Amazon 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 [Amazon Glacier storage classes](https://aws.amazon.com/s3/storage-classes/glacier/).

Amazon Glacier (original standalone vault-based service) is no longer accepting new customers. Amazon Glacier is a standalone service with its own APIs that stores data in vaults and is distinct from Amazon S3 and the Amazon S3 Glacier storage classes. Your existing data will remain secure and accessible in Amazon Glacier indefinitely. No migration is required. For low-cost, long-term archival storage, AWS recommends the [Amazon S3 Glacier storage classes](https://aws.amazon.com/s3/storage-classes/glacier/), which deliver a superior customer experience with S3 bucket-based APIs, full AWS Region availability, lower costs, and AWS service integration. If you want enhanced capabilities, consider migrating to Amazon S3 Glacier storage classes by using our [AWS Solutions Guidance for transferring data from Amazon Glacier vaults to Amazon S3 Glacier storage classes](https://aws.amazon.com/solutions/guidance/data-transfer-from-amazon-s3-glacier-vaults-to-amazon-s3/).

# Deleting an Archive in Amazon Glacier
Deleting an Archive

You cannot delete an archive using the Amazon Glacier (Amazon Glacier) management console. To delete an archive you must use the AWS Command Line Interface (CLI) or write code to make a delete request using either the REST API directly or the AWS SDK for Java and .NET wrapper libraries. The following topics explain how to use the AWS SDK for Java and .NET wrapper libraries, the REST API, and the AWS CLI.

**Topics**
+ [

# Deleting an Archive in Amazon Glacier Using the AWS SDK for Java
](deleting-an-archive-using-java.md)
+ [

# Deleting an Archive in Amazon Glacier Using the AWS SDK for .NET
](deleting-an-archive-using-dot-net.md)
+ [

# Deleting an Amazon Glacier Archive Using the REST API
](deleting-an-archive-using-rest.md)
+ [

# Deleting an Archive in Amazon Glacier Using the AWS Command Line Interface
](deleting-an-archive-using-cli.md)

You can delete one archive at a time from a vault. To delete the archive you must provide its archive ID in your delete request. You can get the archive ID by downloading the vault inventory for the vault that contains the archive. For more information about downloading the vault inventory, see [Downloading a Vault Inventory in Amazon Glacier](vault-inventory.md). 

After you delete an archive, you might still be able to make a successful request to initiate a job to retrieve the deleted archive, but the archive retrieval job will fail. 

Archive retrievals that are in progress for an archive ID when you delete the archive might or might not succeed according to the following scenarios:

 
+ If the archive retrieval job is actively preparing the data for download when Amazon Glacier receives the delete archive request, then the archival retrieval operation might fail. 
+ If the archive retrieval job has successfully prepared the archive for download when Amazon Glacier receives the delete archive request, then you will be able to download the output. 

For more information about archive retrieval, see [Downloading an Archive in Amazon Glacier](downloading-an-archive.md). 

This operation is idempotent. Deleting an already-deleted archive does not result in an error. 

After you delete an archive, if you immediately download the vault inventory, it might include the deleted archive in the list because Amazon Glacier prepares vault inventory only about once a day.

**Note**  
For automated deletion of vault archives, see [Automated deletion of vault archives in Amazon S3 Glacier](https://aws.amazon.com/solutions/guidance/automated-deletion-of-vault-archives-in-amazon-s3-glacier/).

# Deleting an Archive in Amazon Glacier Using the AWS SDK for Java
Deleting an Archive Using Java

The following are the steps to delete an archive using the AWS SDK for Java low-level API.

 

1. Create an instance of the `AmazonGlacierClient` class (the client). 

   You need to specify an AWS Region where the archive you want to delete is stored. All operations you perform using this client apply to that AWS Region. 

1. Provide request information by creating an instance of the `DeleteArchiveRequest` class.

   You need to provide an archive ID, a vault name, and your account ID. If you don't provide an account ID, then account ID associated with the credentials you provide to sign the request is assumed. For more information, see [Using the AWS SDK for Java with Amazon Glacier](using-aws-sdk-for-java.md).

1. Run the `deleteArchive` method by providing the request object as a parameter. 

The following Java code snippet illustrates the preceding steps.

```
AmazonGlacierClient client;

DeleteArchiveRequest request = new DeleteArchiveRequest()
    .withVaultName("*** provide a vault name ***")
    .withArchiveId("*** provide an archive ID ***");

client.deleteArchive(request);
```

 

**Note**  
For information about the underlying REST API, see [Delete Archive (DELETE archive)](api-archive-delete.md).

## Example: Deleting an Archive Using the AWS SDK for Java


The following Java code example uses the AWS SDK for Java to delete an archive. For step-by-step instructions on how to run this example, see [Running Java Examples for Amazon Glacier Using Eclipse](using-aws-sdk-for-java.md#setting-up-and-testing-sdk-java). You need to update the code as shown with a vault name and the archive ID of the archive you want to delete.

**Example**  

```
import java.io.IOException;

import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.glacier.AmazonGlacierClient;
import com.amazonaws.services.glacier.model.DeleteArchiveRequest;

public class ArchiveDelete {

    public static String vaultName = "*** provide vault name ****";
    public static String archiveId = "*** provide archive ID***";
    public static AmazonGlacierClient client;
    
    public static void main(String[] args) throws IOException {
        
    	ProfileCredentialsProvider credentials = new ProfileCredentialsProvider();

        client = new AmazonGlacierClient(credentials);
        client.setEndpoint("https://glacier.us-east-1.amazonaws.com/");        

        try {

            // Delete the archive.
            client.deleteArchive(new DeleteArchiveRequest()
                .withVaultName(vaultName)
                .withArchiveId(archiveId));
            
            System.out.println("Deleted archive successfully.");
            
        } catch (Exception e) {
            System.err.println("Archive not deleted.");
            System.err.println(e);
        }
    }
}
```

# Deleting an Archive in Amazon Glacier Using the AWS SDK for .NET
Deleting an Archive Using .NET

Both the [high-level and low-level APIs](using-aws-sdk.md) provided by the Amazon SDK for .NET provide a method to delete an archive.

**Topics**
+ [

## Deleting an Archive Using the High-Level API of the AWS SDK for .NET
](#delete-archive-using-dot-net-high-level)
+ [

## Deleting an Archive Using the Low-Level API AWS SDK for .NET
](#delete-archive-using-dot-net-low-level)

## Deleting an Archive Using the High-Level API of the AWS SDK for .NET


The `ArchiveTransferManager` class of the high-level API provides the `DeleteArchive` method you can use to delete an archive. 

### Example: Deleting an Archive Using the High-Level API of the AWS SDK for .NET


The following C\$1 code example uses the high-level API of the AWS SDK for .NET to delete an archive. For step-by-step instructions on how to run this example, see [Running Code Examples](using-aws-sdk-for-dot-net.md#setting-up-and-testing-sdk-dotnet). You need to update the code as shown with the archive ID of the archive you want to delete.

**Example**  

```
using System;
using Amazon.Glacier;
using Amazon.Glacier.Transfer;
using Amazon.Runtime; 

namespace glacier.amazon.com.rproxy.govskope.ca.docsamples
{
  class ArchiveDeleteHighLevel
  {
    static string vaultName = "examplevault";
    static string archiveId = "*** Provide archive ID ***";

    public static void Main(string[] args)
    {
      try
      {
        var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2);
        manager.DeleteArchive(vaultName, archiveId);
        Console.ReadKey();
      }
      catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
      catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
      catch (Exception e) { Console.WriteLine(e.Message); }
      Console.WriteLine("To continue, press Enter");
      Console.ReadKey();
    }
  }
}
```

## Deleting an Archive Using the Low-Level API AWS SDK for .NET


The following are the steps to delete an using the AWS SDK for .NET.

 

1. Create an instance of the `AmazonGlacierClient` class (the client). 

   You need to specify an AWS Region where the archive you want to delete is stored. All operations you perform using this client apply to that AWS Region. 

1. Provide request information by creating an instance of the `DeleteArchiveRequest` class.

   You need to provide an archive ID, a vault name, and your account ID. If you don't provide an account ID, then account ID associated with the credentials you provide to sign the request is assumed. For more information, see [Using the AWS SDKs with Amazon Glacier](using-aws-sdk.md).

1. Run the `DeleteArchive` method by providing the request object as a parameter. 

### Example: Deleting an Archive Using the Low-Level API of the AWS SDK for .NET


The following C\$1 example illustrates the preceding steps. The example uses the low-level API of the AWS SDK for .NET to delete an archive.

**Note**  
For information about the underlying REST API, see [Delete Archive (DELETE archive)](api-archive-delete.md).

 For step-by-step instructions on how to run this example, see [Running Code Examples](using-aws-sdk-for-dot-net.md#setting-up-and-testing-sdk-dotnet). You need to update the code as shown with the archive ID of the archive you want to delete.

**Example**  

```
using System;
using Amazon.Glacier;
using Amazon.Glacier.Model;
using Amazon.Runtime;

namespace glacier.amazon.com.rproxy.govskope.ca.docsamples
{
  class ArchiveDeleteLowLevel
  {
    static string vaultName = "examplevault";
    static string archiveId = "*** Provide archive ID ***";

    public static void Main(string[] args)
    {
      AmazonGlacierClient client;
      try
      {
        using (client = new AmazonGlacierClient(Amazon.RegionEndpoint.USWest2))
        {
          Console.WriteLine("Deleting the archive");
          DeleteAnArchive(client);
        }
        Console.WriteLine("Operations successful. To continue, press Enter");
        Console.ReadKey();
      }
      catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
      catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
      catch (Exception e) { Console.WriteLine(e.Message); }
      Console.WriteLine("To continue, press Enter");
      Console.ReadKey();
    }

    static void DeleteAnArchive(AmazonGlacierClient client)
    {
      DeleteArchiveRequest request = new DeleteArchiveRequest()
      {
        VaultName = vaultName,
        ArchiveId = archiveId
      };
      DeleteArchiveResponse response = client.DeleteArchive(request);
    }
  }
}
```

# Deleting an Amazon Glacier Archive Using the REST API
Deleting an Archive Using REST

You can use the Delete Archive API to delete an archive. 
+ For information about the Delete Archive API, see [Delete Archive (DELETE archive)](api-archive-delete.md).
+ For information about using the REST API, see [API Reference for Amazon Glacier](amazon-glacier-api.md). 

# Deleting an Archive in Amazon Glacier Using the AWS Command Line Interface
Deleting an Archive Using the AWS CLI

You can delete archives in Amazon Glacier (Amazon Glacier) using the AWS Command Line Interface (AWS CLI).

**Topics**
+ [

## (Prerequisite) Setting Up the AWS CLI
](#Creating-Vaults-CLI-Setup)
+ [

## Example: Deleting an Archive Using the AWS CLI
](#Deleting-Archives-CLI-Implementation)

## (Prerequisite) Setting Up the AWS CLI


1. Download and configure the AWS CLI. For instructions, see the following topics in the *AWS Command Line Interface User Guide*: 

    [Installing the AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) 

   [Configuring the AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)

1. Verify your AWS 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 Amazon Glacier vaults on the configured account, use the `list-vaults` command. Replace *123456789012* with your AWS account ID.

     ```
     aws glacier list-vaults --account-id 123456789012
     ```
   + To see the current configuration data for the AWS CLI, use the `aws configure list` command.

     ```
     aws configure list
     ```

## Example: Deleting an Archive Using the AWS CLI


1. Use the [http://docs.aws.amazon.com/cli/latest/reference/glacier/initiate-job.html](http://docs.aws.amazon.com/cli/latest/reference/glacier/initiate-job.html) command to start an inventory retrieval job.

   ```
   aws glacier initiate-job --vault-name awsexamplevault --account-id 111122223333 --job-parameters="{\"Type\":\"inventory-retrieval\"}"
   ```

    Expected output:

   ```
   {
       "location": "/111122223333/vaults/awsexamplevault/jobs/*** jobid ***", 
       "jobId": "*** jobid ***"
   }
   ```

1. Use the [http://docs.aws.amazon.com/cli/latest/reference/glacier/describe-job.html](http://docs.aws.amazon.com/cli/latest/reference/glacier/describe-job.html) command to check status of the previous retrieval job.

   ```
   aws glacier describe-job --vault-name awsexamplevault --account-id 111122223333 --job-id *** jobid ***
   ```

    Expected output:

   ```
   {
       "InventoryRetrievalParameters": {
           "Format": "JSON"
       }, 
       "VaultARN": "*** vault arn ***", 
       "Completed": false, 
       "JobId": "*** jobid ***", 
       "Action": "InventoryRetrieval", 
       "CreationDate": "*** job creation date ***", 
       "StatusCode": "InProgress"
   }
   ```

1. 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, Amazon 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 Glacier](configuring-notifications.md). Amazon Glacier sends a message to the specified SNS topic anytime the specific event occurs.

1. When it's complete, use the [http://docs.aws.amazon.com/cli/latest/reference/glacier/get-job-output.html](http://docs.aws.amazon.com/cli/latest/reference/glacier/get-job-output.html) command to download the retrieval job to the file `output.json`.

   ```
   aws glacier get-job-output --vault-name awsexamplevault --account-id 111122223333 --job-id *** jobid *** output.json
   ```

   This 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":
   ...
   ]}
   ```

1. Use the `delete-archive` command to delete each archive from a vault until none remain.

   ```
   aws glacier delete-archive --vault-name awsexamplevault --account-id 111122223333 --archive-id *** archiveid ***
   ```