AWS Builder Center

Build a Serverless REST API with AWS Lambda and API Gateway

Learn how to build a simple serverless REST API using Amazon API Gateway and AWS Lambda without managing servers.

Build a Serverless REST API with AWS Lambda and API Gateway

Building an API traditionally requires setting up and maintaining servers. With AWS serverless services, we can create an API without managing any servers.
In this tutorial, we will create a simple REST API using Amazon API Gateway and AWS Lambda.

What We Will Build

Our architecture will look like this:
Client → API Gateway → Lambda → Response
The client sends an HTTP request to API Gateway. API Gateway invokes the Lambda function, and Lambda processes the request and returns a response.

Step 1: Create a Lambda Function

Open the AWS Management Console and navigate to AWS Lambda.
Create a new function and choose:
  • Author from scratch
  • Runtime: Python
  • Architecture: x86_64
Give your function a name such as:
 hello-api 
Use the following Python code:
def lambda_handler(event, context):
return {
"statusCode": 200,
"body": "Hello from AWS Lambda!"
}
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article