AWS Lambda (original) (raw)

Last Updated : 8 Jun, 2026

AWS Lambda is a serverless compute service that runs your code only when triggered by an event, scales automatically, and charges only for the milliseconds of execution time used. Its key features are:

Benefits of AWS Lambda

The Event-Driven Model

Every Lambda execution follows a three-part pattern.

**Example: A new image uploaded to an S3 bucket triggers a Lambda function that resizes the image and saves the result to a separate S3 bucket.

When you write a Lambda function (in Python, Node.js, Java, etc.), you are primarily interacting with three components. Here is a standard Python example:

def lambda_handler(event, context):
# 1. The Handler
print("Received event:", event)

# Your business logic here  
message = "Hello, " + event.get("key1", "World")  
  
return {  
    'statusCode': 200,  
    'body': message  
}

Use Cases of AWS Lambda Functions

**Use Case **Description **Example
**File Processing Automatically process files as they arrive. A user uploads a photo to **S3; Lambda triggers instantly to create a thumbnail version.
**Web APIs Build serverless backends. An HTTP request hits API Gateway; Lambda runs the logic to fetch data and return it to the user.
**Data Streams Process real-time data. IoT sensors send temperature data to Kinesis; Lambda filters and analyzes it in real-time.
**Cron Jobs Scheduled automation. EventBridge triggers a Lambda function every night at 12:00 AM to generate daily reports.

AWS lambda will help you to focus more on your code than the underlying infrastructure. The infrastructure maintenance in AWS was taken care of by AWS lambda.

Working of AWS Lambda Functions

Start off by uploading the code to AWS Lambda. From there, set up the code to trigger from other AWS services, HTTP endpoints, or mobile apps. AWS Lambda will only run the code when it's triggered and will also only use the computing resources needed to run it. The user has to pay only for the compute time used.

AWS (Amazon Web Services) Lambda

Getting Started With AWS Lambda Function

The following are the steps mentioned below to create your own customized AWS lambda functions by using the AWS console. Create an AWS account.

**Step 1: Log in to your AWS console and search for Lambda. As shown in the following image.

Lambda

**Step 2: Click on Create function.

Create Function

**Step 3: Here we are going to use a sample hello world program by using Author from scratch and configure the details according to your requirement.

Configure the function

**Step 4: Successfully our function is created.

Function Created

Pricing

AWS Lambda offers a generous Free Tier that includes 1 Million requests and 400,000 GB-seconds of compute time per month forever. Beyond the free tier, you are billed on two factors:

**Note: If your code is inefficient and takes 10 seconds to run, you pay for 10 seconds. If you optimize it to run in 200ms, your bill drops significantly.

Common Use Cases

Monitoring Your AWS Lambda Usage

Monitoring your AWS Lambda usage is crucial for understanding and controlling costs, especially as your workloads scale beyond the AWS Free Tier limits. Here are some ways to effectively track and manage Lambda usage: