Search code examples
pythonlambdaaws-event-bridge

Check if eventbridge schedule is existing


I want to Check if eventbridge schedule is existing , Or not .. When I use response=client.get_schedule( Name='Name of the schedule' )

It will return the details of the schedule if it's existing , But it will throw exception and will not return any values if it's not existing which breaks the code . I'm using python on lambda .


Solution

  • The simplest way would be to wrap this line around with

    try:
        response = client.describe_rule(Name='Name of the schedule')
    except ResourceNotFoundException as err:
        # decide what to do here
    

    boto3 docs eventbridge client describe_rule