Invoking Lambda with API Gateway - 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).

Invoking Lambda with API Gateway

You can invoke an Lambda function by using Amazon API Gateway, which is an Amazon service for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket APIs at scale. API developers can create APIs that access Amazon or other web services, as well as data stored in the Amazon Cloud. As an API Gateway developer, you can create APIs for use in your own client applications. For more information, see What is Amazon API Gateway.

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 example, 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 example should take about 20 minutes to complete.

This example 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 API Gateway to invoke this Amazon Lambda function by using a Rest endpoint. For example, you can invoke the Lambda function by using this curl command:

curl -XGET ""

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

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 example to ensure that you are not charged.