

 **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/).

# Step 5: Delete an Archive from a Vault in Amazon Glacier
<a name="getting-started-delete-archive"></a>

In this step, you'll delete the sample archive that you uploaded in [Step 3: Upload an Archive to a Vault in Amazon Glacier](getting-started-upload-archive.md). 

**Important**  
You cannot delete an archive by using the Amazon Glacier console. Any archive operation, such as upload, download, or deletion, requires you to use the AWS Command Line Interface (CLI) or write code. To upload data, such as photos, videos, and other documents, you must either use the AWS CLI or write code to make requests, by using either the REST API directly or by using the AWS SDKs.  
To install the AWS CLI, see [AWS Command Line Interface](http://aws.amazon.com/cli/). For more information about using Amazon Glacier with the AWS CLI, see [AWS CLI Reference for Amazon Glacier](http://docs.aws.amazon.com/cli/latest/reference/glacier/index.html). For examples of using the AWS CLI to upload archives to Amazon Glacier, see [Using Amazon Glacier with the AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/cli-using-glacier.html). 

Delete the sample archive by following one of these SDKs or the AWS CLI: 
+ [Delete an Archive from a Vault in Amazon Glacier by Using the AWS SDK for Java](getting-started-delete-archive-java.md)
+ [Delete an Archive from a Vault in Amazon Glacier by Using the AWS SDK for .NET](getting-started-delete-archive-dotnet.md)
+ [Delete an Archive in Amazon Glacier by Using the AWS CLI](getting-started-delete-archive-cli.md)

## Related Sections
<a name="getting-started-delete-archive-related-sections"></a>

 
+ [Step 3: Upload an Archive to a Vault in Amazon Glacier](getting-started-upload-archive.md)
+ [Deleting an Archive in Amazon Glacier](deleting-an-archive.md)

# Delete an Archive from a Vault in Amazon Glacier by Using the AWS SDK for Java
<a name="getting-started-delete-archive-java"></a>

The following code example uses the AWS SDK for Java to delete the archive. In the code, note the following:

 
+ The `DeleteArchiveRequest` object describes the delete request, including the vault name where the archive is located and the archive ID.
+ The `deleteArchive` API operation sends the request to Amazon Glacier to delete the archive. 
+ The example uses the US West (Oregon) Region (`us-west-2`). 

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 must update the code as shown with the archive ID of the file that you uploaded in [Step 3: Upload an Archive to a Vault in Amazon Glacier](getting-started-upload-archive.md). 

**Example — Deleting an Archive by Using the AWS SDK for Java**  <a name="GS_ExampleDeleteArchiveJava"></a>

```
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 AmazonGlacierDeleteArchive_GettingStarted {

    public static String vaultName = "examplevault";
    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-west-2.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);
        }
    }
}
```

# Delete an Archive from a Vault in Amazon Glacier by Using the AWS SDK for .NET
<a name="getting-started-delete-archive-dotnet"></a>

The following C\$1 code example uses the high-level API of the AWS SDK for .NET to delete the archive that you uploaded in the previous step. In the code example, note the following: 
+ The example creates an instance of the `ArchiveTransferManager` class for the specified Amazon Glacier Region endpoint.
+ The code example uses the US West (Oregon) Region (`us-west-2`). 
+ The example uses the `Delete` API operation of the `ArchiveTransferManager` class that's provided as part of the high-level API of the AWS SDK for .NET. 

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 must update the code as shown with the archive ID of the file that you uploaded in [Step 3: Upload an Archive to a Vault in Amazon Glacier](getting-started-upload-archive.md). 

**Example — Deleting an Archive by Using the High-Level API of the AWS SDK for .NET**  <a name="GS_ExampleDeleteArchiveDotNet"></a>

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

namespace glacier.amazon.com.rproxy.govskope.ca.docsamples
{
  class ArchiveDeleteHighLevel_GettingStarted
  {
    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);
      }
      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();
    }
  }
}
```

# Delete an Archive in Amazon Glacier by Using the AWS CLI
<a name="getting-started-delete-archive-cli"></a>

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

**Topics**
+ [(Prerequisite) Setting Up the AWS CLI](#Creating-Vaults-CLI-Setup)
+ [Example: Deleting an Archive by Using the AWS CLI](#getting-started-Deleting-Archives-CLI-Implementation)

## (Prerequisite) Setting Up the AWS CLI
<a name="Creating-Vaults-CLI-Setup"></a>

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 by Using the AWS CLI
<a name="getting-started-Deleting-Archives-CLI-Implementation"></a>

1. Use the `initiate-job` command to start an inventory retrieval job. For more information on the `initiate-job` command, see [Initiate Job](https://docs.aws.amazon.com/amazonglacier/latest/dev/api-initiate-job-post.html).

   ```
   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 `describe-job` command to check the status of the previous retrieval job. For more information on the `describe-job` command, see [Describe Job](https://docs.aws.amazon.com/amazonglacier/latest/dev/api-describe-job-get.html).

   ```
   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 be completed.

   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 Amazon SNS topic anytime the specific event occurs.

1. When the job is complete, use the `get-job-output` command to download the retrieval job to the file `output.json`. For more information on the `get-job-output` command, see [Get Job Output](https://docs.aws.amazon.com/amazonglacier/latest/dev/api-job-output-get.html).

   ```
   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": 123456789
   
   }
   ```

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 ***"
   ```

 For more information on the `delete-archive` command, see [Delete Archive](https://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-delete.html).