A common use case for AWS Lambda functions is to run them regularly on a schedule. This can be used in a wide range of scenarios, from periodically performing some web scraping to sending out regular updates using SNS. In this blog post, I’ll walk through the steps you need to take to start running your Lambda function on a schedule using only the AWS console.
Creating an EventBridge rule
Assuming you have already implemented a Lambda function you would like to schedule, start by navigating to Amazon EventBridge in your AWS console.
Click “Create rule”. Give the rule a name, then under “Define pattern”, select “Schedule”. For most simple use cases, you can just use “Fixed rate every” to set a schedule for every X number of Minutes, Hours or Days. For more granular control over the scheduling, you can also provide a CRON expression.
Next we need to set our Lambda function as the target which will be invoked by the scheduled event. Under the “Select targets” section, select “Lambda function” and find your function in the following dropdown.
Finally, click “Create” at the bottom of the page. That’s all you need to do, your Lambda function will now be invoked according to the schedule you configured.
You can double-check that your Lambda is now running on schedule by opening CloudWatch and showing Invocations for your Lambda function.