Run Lambda Functions on a Schedule using Amazon EventBridge Event Rules

Amazon EventBridge is a serverless event bus service that makes it easy to connect your applications with data from a variety of sources. You can create rules that self-trigger on an automated schedule in EventBridge using cron or rate expressions. These rules can in-turn trigger Lambda functions, even with custom input if required. All scheduled events use UTC time zone & the minimum precision for schedules is 1 minute.

A rule watches for certain events and then routes them to AWS targets that you choose. You can create a rule that performs an AWS action automatically when another AWS action happens, or a rule that performs an AWS action regularly on a set schedule. To create a schedule for a Lambda function, open, select your region & start by providing a name for the rule:

Next, select Schedule & provide a rate at which the Lambda function should be invoked, every minute for example:

Choosing Schedule makes this a rule that is triggered regularly on the schedule you specify. You can use a simple fixed-rate schedule that triggers every certain number of minutes, hour, or weeks, or you can use a cron expression to create a more fine-grained schedule, such as “the first Monday of each month at 8am.” See the documentation for a comprehensive reference of how to design cron expressions.

Next, select the Lambda function you want triggered every time this rule triggers:

By default, the $latest version of the function is invoked. If you want to invoke a particular version or alias, select it from the dropdown:

You can also customize the input that is provided to your function when it’s triggered:

By default, a JSON is provided to the function as input which represents the EventBridge event that caused it to be triggered.

  • If you choose Matched events, the entire event pattern text is passed to the target when the rule is triggered.
  • If you choose Part of the matched event, only the part of the event text that you specify is passed to the target. For example, if you specify $.detail, then only the Detail part of the event pattern is passed.
  • If you choose Constant (JSON text), no part of the event text is passed to the target. Instead, only the JSON text that you specify in this box is passed to the target.
  • If you choose Input transformer, you specify how to change some of the event text before passing it to the target. One or more JSON paths are extracted from the event text and used in a template that you provide.

Finally, click Create at the end of the page to create the schedule. Your Lambda will now be automatically triggered regularly.