Creating scheduled events to execute Amazon Lambda functions - Amazon SDK for JavaScript
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

The Amazon SDK for JavaScript V3 API Reference Guide describes in detail all the API operations for the Amazon SDK for JavaScript version 3 (V3).

Starting October 1, 2022, Amazon SDK for JavaScript (v3) will end support for Internet Explorer 11 (IE 11). For details, see Announcing the end of support for Internet Explorer 11 in the Amazon SDK for JavaScript (v3).

Creating scheduled events to execute Amazon Lambda functions

You can create a scheduled event that invokes an Amazon Lambda function by using an Amazon CloudWatch Event. You can configure a CloudWatch Event to use a cron expression to schedule when a Lambda function is invoked. For example, you can schedule a CloudWatch Event to invoke an Lambda function every weekday.

Amazon Lambda is a compute service that enables you to run code without provisioning or managing servers. You can create Lambda functions in various programming languages. For more information about Amazon Lambda, see What is Amazon Lambda.

In this tutorial, you create a Lambda function by using the Lambda JavaScript runtime API. This example invokes different Amazon services to perform a specific use case. For example, assume that an organization sends a mobile text message to its employees that congratulates them at the one year anniversary date, as shown in this illustration.


                DynamoDB table

The tutorial should take about 20 minutes to complete.

This tutorial shows you how to use JavaScript logic to create a solution that performs this use case. For example, you'll learn how to read a database to determine which employees have reached the one year anniversary date, how to process the data, and send out a text message all by using a Lambda function. Then you’ll learn how to use a cron expression to invoke the Lambda function every weekday.

This Amazon tutorial uses an Amazon DynamoDB table named Employee that contains these fields.

  • id - the primary key for the table.

  • firstName - employee’s first name.

  • phone - employee’s phone number.

  • startDate - employee’s start date.


                DynamoDB table
Important

Cost to complete: The Amazon services included in this document are included in the Amazon Free Tier. However, be sure to terminate all of the resources after you have completed this tutorial to ensure that you are not charged.