Scheduling an AWS Lambda Function Using Amazon EventBridge Scheduler

Lab Steps

lock
Logging In to the Amazon Web Services Console
lock
Creating an AWS Lambda Function for Scheduling
lock
Scheduling an AWS Lambda Function Using Amazon EventBridge Scheduler
lock
Verifying Your AWS Lambda Function Is Running on a Schedule
lock
Creating a Dashboard to Monitor your AWS Lambda function
Need help? Contact our support team

Here you can find the instructions for this specific Lab Step.

If you are ready for a real environment experience please start the Lab. Keep in mind that you'll need to start from the first step.

Introduction

Amazon EventBridge Scheduler allows you to create, run, and manage scheduled tasks at scale. With EventBridge Scheduler, you can create one-time or recurring schedules that run tasks on your behalf using various target APIs. Each schedule can be configured to run tasks within a specified time window, perform retries for failed tasks, and also send failed tasks into a dead letter queue for further investigation.  

In this Lab Step, you will create a schedule using EventBridge Scheduler to invoke your Lambda function every minute.

 

Instructions

1. In the AWS Management Console search bar, enter scheduler, and click the Amazon EventBridge Scheduler result under Services:

alt

 

2. Click Create schedule:

alt

The schedule detail form will appear.

 

3. Enter lab-schedule for the Schedule name, and ensure the default Schedule group is selected:

alt

alt

Placing your schedules into separate groups allows you to add tags and organize them by pattern or objective.

Note: Leave any unspecified fields as their defaults for the following instructions

 

4. Configure the following for the Schedule pattern:

  • Occurence: Select Recurring schedule
  • Schedule type: Select Rate-based schedule
  • Rate expression: Enter a Value of 1 and select a Unit of minutes from the drop-down menu
  • Flexible time window: Select Off from the drop-down menu

alt

The schedule will invoke your Lambda function every minute on a recurring schedule. A flexible time window is not necessary for this lab.

You won't be configuring a timeframe for this schedule. The schedule will start the recurring invocation of the target Lambda function when the schedule is created.

 

5. Click Next:

alt

 

6. Ensure Templated targets option is selected, then select the AWS Lambda Invoke target API:

alt

alt

 

7. In the Invoke section of the page, select lab-function from the Lambda function drop-down menu, and click Next:

alt

 

8. On the Settings page, scroll down for the Retry policy and dead-letter queue section and deselect the Retry policy option:

alt

EventBridge scheduler will retry any failed Lambda invocations for up to 24 hours by default. This is helpful when dealing with an unresponsive target as the scheduler can be configured to retry until the target is operational again.

 

9. Scroll down to the Permissions section and configure the following:

  • Execution role: Select Use existing role
  • Select an existing role: Select the scheduler_role from the drop-down menu

alt

The scheduler_role is an IAM Role that was preconfigured for you at the start of this lab. The role contains a policy that grants this schedule permission to use the lambda:InvokeFunction action on your Lambda function.

 

10. Click Next, then Create schedule on the review page:

alt

The following notification will appear to inform you that the schedule has been created:

alt

You have configured this schedule to invoke your Lambda function every minute.

 

Summary

In this Lab Step, you created an EventBridge schedule that invokes your Lambda function every minute.

Validation checks
1Checks
Created a new Amazon EventBridge schedule

Check if the EventBridge schedule has been created for this lab

Amazon EventBridge