This website uses cookies

Read our Privacy policy and Terms of use for more information.

Hands-on AWS content is highly valuable for practical learning.
As part of AWS Hands-on Topics covering all major AWS services, today will start with …

AWS Lambda: Build & Deploy Your First Function.

Step 1: Prerequisites

Before starting, ensure to have:
βœ… An AWS Free Tier account
βœ… AWS CLI installed and configured (aws configure)
βœ… IAM user with Lambda permissions
βœ… Node.js or Python installed (for function development)

Step 2: Create an IAM Role for Lambda

AWS Lambda needs execution permissions.

1️⃣ Go to IAM β†’ Roles β†’ Create Role
2️⃣ Select AWS service β†’ Lambda β†’ Click "Next"


3️⃣ Attach the following permissions:

AWSLambdaBasicExecutionRole

AWSLambdaVPCAccessExecutionRole (if using VPC)

4️⃣ Name the role (e.g., LambdaExecutionRole) and create it.

Step 3: Create an AWS Lambda Function (Console)

1️⃣ Open AWS Lambda in the AWS Management Console
2️⃣ Click Create Function
3️⃣ Select Author from Scratch
4️⃣ Function Name: hello-world-lambda
5️⃣ Runtime: Choose Python 3.13
6️⃣ Execution Role: Select the IAM Role created earlier
7️⃣ Click Create Function

Step 4: Write Your First Lambda Function

If using Python:

Replace the default code with:

import json

def lambda_handler(event, context):

return {

"statusCode": 200,

"body": json.dumps("Hello from AWS Lambda!")

}

Click Deploy

Step 5: Test Your Lambda Function

1️⃣ Click on Test

2️⃣ Configure a new test event with { "key": "value" }
3️⃣ Click Test again
βœ… You should see "Hello from AWS Lambda!" in the response

Step 6: Clean Up Resources

To avoid unnecessary AWS charges: delete lambda function

CLI command:

aws lambda delete-function --function-name hello-world-lambda

π˜Ύπ’π™£π’ˆπ™§π’‚π™©π’–π™‘π’‚π™©π’Šπ™€π’π™¨! 𝒀𝙀𝒖 𝒋π™ͺ𝒔𝙩 π™—π’–π™žπ’π™© & 𝙙𝒆π™₯π’π™€π’šπ™šπ’… π’šπ™€π’–π™§ π™›π’Šπ™§π’”π™© π˜Όπ‘Ύπ™Ž 𝙇𝒂𝙒𝒃𝙙𝒂 𝒇π™ͺπ’π™˜π’•π™žπ’π™£!

Other things, we can do with AWS Lambda

❏ Invoke Lambda Function via AWS CLI

Run the following command:

aws lambda invoke --function-name hello-world-lambda output.json

Check output.json to see the response.

❏ Trigger Lambda with API Gateway

To invoke Lambda via HTTP:
1️⃣ Go to AWS API Gateway
2️⃣ Create a REST API
3️⃣ Create a new resource & method (GET)
4️⃣ Integrate it with Lambda Function
5️⃣ Deploy the API β†’ Get the Invoke URL
6️⃣ Test via browser or Postman

Reply

Avatar

or to participate