Use DescribeJob with an AWS SDK or CLI - Amazon S3 Glacier

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

If you're looking for archival storage solutions we suggest using the S3 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 S3 Glacier storage classes and Long-term data storage using S3 Glacier storage classes in the Amazon S3 User Guide. These storage classes use the Amazon S3 API, are available in all regions, and can be managed within the Amazon S3 console. They offer features like Storage Cost Analysis, Storage Lens, security features including multiple encryption options, and more.

Use DescribeJob with an AWS SDK or CLI

The following code examples show how to use DescribeJob.

CLI
AWS CLI

The following command retrieves information about an inventory retrieval job on a vault named my-vault:

aws glacier describe-job --account-id - --vault-name my-vault --job-id zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW

Output:

{ "InventoryRetrievalParameters": { "Format": "JSON" }, "VaultARN": "arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault", "Completed": false, "JobId": "zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW", "Action": "InventoryRetrieval", "CreationDate": "2015-07-17T20:23:41.616Z", "StatusCode": "InProgress" }

The job ID can be found in the output of aws glacier initiate-job and aws glacier list-jobs. Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.

  • For API details, see DescribeJob in AWS CLI Command Reference.

PowerShell
Tools for PowerShell

Example 1: Returns details of the specified job. When the job completes successfully the Read-GCJobOutput cmdlet can be used to retrieve the contents of the job (an archive or inventory list) to the local file system.

Get-GLCJob -VaultName myvault -JobId "op1x...JSbthM"

Output:

Action : ArchiveRetrieval ArchiveId : o9O9j...X-TpIhQJw ArchiveSHA256TreeHash : 79f3ea754c02f58...dc57bf4395b ArchiveSizeInBytes : 38034480 Completed : False CompletionDate : 1/1/0001 12:00:00 AM CreationDate : 12/13/2018 11:00:14 AM InventoryRetrievalParameters : InventorySizeInBytes : 0 JobDescription : JobId : op1x...JSbthM JobOutputPath : OutputLocation : RetrievalByteRange : 0-38034479 SelectParameters : SHA256TreeHash : 79f3ea754c02f58...dc57bf4395b SNSTopic : StatusCode : InProgress StatusMessage : Tier : Standard VaultARN : arn:aws:glacier:us-west-2:012345678912:vaults/test
  • For API details, see DescribeJob in AWS Tools for PowerShell Cmdlet Reference.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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 get_job_status(job): """ Gets the status of a job. :param job: The job to query. :return: The current status of the job. """ try: job.load() logger.info( "Job %s is performing action %s and has status %s.", job.id, job.action, job.status_code, ) except ClientError: logger.exception("Couldn't get status for job %s.", job.id) raise else: return job.status_code
  • For API details, see DescribeJob in AWS SDK for Python (Boto3) API Reference.

For a complete list of AWS SDK developer guides and code examples, see Using S3 Glacier with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.