Using AWS EventBridge to Schedule Lambda Functions

Overview

This article explains how to use AWS EventBridge to schedule Lambda functions for periodic execution.

What is AWS EventBridge?

AWS EventBridge is a service that facilitates the passing of events between AWS services, enabling the creation of event-driven architectures. For a detailed explanation, refer to the AWS official documentation on EventBridge.

Prerequisites

It is assumed that you have already created a Lambda function. For instructions on creating Lambda functions, please see the AWS Lambda Getting Started guide.

Steps to Schedule a Lambda Function with EventBridge

To schedule your Lambda function with EventBridge, follow these steps:

  1. Select the Lambda Function: Open the AWS Management Console, navigate to the Lambda service, and select the function you want to schedule.

    Trigger addition screen

  2. Add a Trigger: Choose ‘Add trigger’ and select ‘EventBridge (CloudWatch Events)’ from the list of available triggers.

    Selecting EventBridge

  3. Create a Rule: Once you select EventBridge, you will be prompted to create a new rule. Set up the rule to trigger the Lambda function at desired intervals. For this tutorial, we are using a cron expression to execute the function every 5 minutes. You can find more about cron syntax in the EventBridge Scheduler documentation.

    Trigger configuration

  4. Complete the Setup: After configuring the rule, it will appear in the Lambda function’s diagram as an associated trigger.

    Configuration completion screen

  5. Test the Setup: As a practical application, I set up a function to send messages to LINE. The setup now sends notifications every 5 minutes, as shown in the screenshot below.

    Notification from EventBridge-triggered Lambda function

Conclusion

We’ve outlined how to use AWS EventBridge to schedule Lambda functions periodically. Remember, leaving the EventBridge setup as is will incur charges, so be sure to delete it if it’s no longer needed.