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

Keep Reading