Overview
Integrating AWS API Gateway with Lambda enables you to call Lambda functions from API Gateway. This article introduces how to integrate AWS API Gateway with Lambda.
Prerequisites
It is assumed that the Lambda function has already been created. If not, please refer to the following article for creation:
Deciding How to Integrate API Gateway with Lambda
When integrating API Gateway with Lambda, you need to consider the following two points:
- The request format for API Gateway
- Whether to use Proxy Integration or Non-Proxy Integration
Request Format for API Gateway
You can choose from the following formats:
- REST API
- HTTP API
- WebSocket API
If you choose to use the REST API format, you will need to decide between REST API and HTTP API. While REST API has more features, it is more expensive than HTTP API. HTTP API is a good choice for simpler requirements.
For a detailed comparison, please refer to the official documentation.
Proxy vs. Non-Proxy Integration
Using Proxy Integration standardizes the format of the response returned from Lambda. It is generally recommended to use Proxy Integration.
Configuration
After creating the Lambda function, select “Add Trigger.”
Choose API Gateway.
Configure the trigger addition as shown below.
Once configured successfully, the screen should look like this.
Access the API endpoint
listed with a tool like curl to execute the Lambda function.
|
|
Summary
This article introduced how to integrate AWS API Gateway with Lambda. By integrating with API Gateway, you can externally invoke Lambda functions at any time.