Use DescribeJob with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

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.