How to use Boto3 to get the details of a job that is bookmarked in AWS Glue Data Catalog?

Example − Retrieve the details of bookmarked job ‘book-job’ in AWS Glue Data Catalog.

Problem Statement − Use boto3 library in Python to retrieve the details of a bookmarked job in AWS Glue Data Catalog.

Approach/Algorithm to solve this problem

Step 1 − Import boto3 and botocore exceptions to handle exceptions.

Step 2bookmarked_job_name is the mandatory parameter. It should have job_name that is already bookmarked, otherwise it will throw EntityNotFoundException.

Step 3 − Create an AWS session using boto3 library. Make sure region_name is mentioned in default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.

Step 4 − Create an AWS client for glue.

Step 5 − Now use get_job_bookmark function and pass bookmarked_job_name as JobName parameter.

Step 6 − It returns the details related to bookmark entry. Note that if job_name is not bookmarked, it will throw an exception as EntityNotFound.

Step 7 − Handle the generic exception if something went wrong while checking the job.


Use the following code to retrieve the details of a bookmarked job in AWS Glue Data Catalog −

import boto3
from botocore.exceptions import ClientError

def retrieves_details_of_bookmarked_job(bookmarked_job_name)
   session = boto3.session.Session()
   glue_client = session.client('glue')
      response = glue_client.get_job_bookmark(JobName=bookmarked_job_name)
      return response
   except ClientError as e:
      raise Exception("boto3 client error in retrieves_details_of_bookmarked_job: " + e.__str__())
   except Exception as e:
      raise Exception("Unexpected error in retrieves_details_of_bookmarked_job: " + e.__str__())


{'JobBookmarkEntry': {'JobName': 'book-job', 'Version': 8, 'Run': 2,
'Attempt': 2, 'PreviousRunId':
30T13:03:43.730Z","INCLUDE_LIST":""}}}'}, 'ResponseMetadata':
{'RequestId': 'bacf1497-***************996f05b3c1', 'HTTPStatusCode':
200, 'HTTPHeaders': {'date': 'Sun, 28 Feb 2021 13:00:19 GMT', 'contenttype': 'application/x-amz-json-1.1', 'content-length': '535',
'connection': 'keep-alive', 'x-amzn-requestid': 'bacf1497-
******************996f05b3c1'}, 'RetryAttempts': 0}}