Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Delete an Amazon S3 Glacier vault using an Amazon SDK
The following code examples show how to delete an Amazon S3 Glacier vault.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- Java
-
- SDK for Java 2.x
-
public static void deleteGlacierVault(GlacierClient glacier, String vaultName) {
try {
DeleteVaultRequest delVaultRequest = DeleteVaultRequest.builder()
.vaultName(vaultName)
.build();
glacier.deleteVault(delVaultRequest);
System.out.println("The vault was deleted!");
} catch(GlacierException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
- Python
-
- SDK for Python (Boto3)
-
class GlacierWrapper:
"""Encapsulates Amazon S3 Glacier API operations."""
def __init__(self, glacier_resource):
"""
:param glacier_resource: A Boto3 Amazon S3 Glacier resource.
"""
self.glacier_resource = glacier_resource
@staticmethod
def delete_vault(vault):
"""
Deletes a vault.
:param vault: The vault to delete.
"""
try:
vault.delete()
logger.info("Deleted vault %s.", vault.name)
except ClientError:
logger.exception("Couldn't delete vault %s.", vault.name)
raise
For a complete list of Amazon SDK developer guides and code examples, see
Using S3 Glacier with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.