How to use Boto3 to delete a trigger from AWS Data Catalog?

AWS Glue triggers are used to start jobs automatically based on schedules or events. Sometimes you need to delete triggers that are no longer needed. Boto3 provides a simple way to delete triggers from the AWS Glue Data Catalog.

Problem Statement

Use boto3 library in Python to delete a trigger that is available in your account.

Example ? Delete a trigger 'test' from your account.

Approach to Delete a Trigger

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

Step 2 ? Pass the parameter trigger_name that should be deleted from AWS Glue Catalog.

Step 3 ? Create an AWS session using boto3 library. Make sure region_name is mentioned in default profile.

Step 4 ? Create an AWS client for glue.

Step 5 ? Call delete_trigger() and pass the trigger_name as Name parameter.

Step 6 ? Handle exceptions if something goes wrong during the deletion process.

Example

Use the following code to delete a trigger from your AWS account ?

import boto3
from botocore.exceptions import ClientError

def delete_a_trigger(trigger_name):
    session = boto3.session.Session()
    glue_client = session.client('glue')
    try:
        response = glue_client.delete_trigger(Name=trigger_name)
        return response
    except ClientError as e:
        raise Exception("boto3 client error in delete_a_trigger: " + str(e))
    except Exception as e:
        raise Exception("Unexpected error in delete_a_trigger: " + str(e))

print(delete_a_trigger("test"))

Output

{'Name': 'test', 'ResponseMetadata': {'RequestId': '75abe5e2-...........-59a9bc617e0f', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Sun, 21 Feb 2021 05:27:11 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '35', 'connection': 'keep-alive', 'x-amzn-requestid': '75abe5e2-..........59a9bc617e0f'}, 'RetryAttempts': 0}}

Key Points

The delete_trigger() method returns response metadata containing:

  • Name ? The name of the deleted trigger
  • ResponseMetadata ? HTTP status code, request ID, and headers
  • HTTPStatusCode: 200 ? Indicates successful deletion

Important: If the trigger is not found in AWS Data Catalog, the method doesn't throw an exception but still returns a successful response.

Alternative Approach

You can also create the client directly without creating a session ?

import boto3
from botocore.exceptions import ClientError

def delete_trigger_direct(trigger_name):
    try:
        glue_client = boto3.client('glue')
        response = glue_client.delete_trigger(Name=trigger_name)
        print(f"Trigger '{trigger_name}' deleted successfully")
        return response
    except ClientError as e:
        print(f"Error deleting trigger: {e}")
        return None

# Delete trigger
delete_trigger_direct("test")

Conclusion

Use boto3.client('glue').delete_trigger() to remove triggers from AWS Glue Data Catalog. The method returns metadata confirming successful deletion, even if the trigger doesn't exist.

Updated on: 2026-03-25T18:16:00+05:30

262 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements