Creating AWS Lambda function using AWS Console in python 3.0

Sanjit Khasnobis
3 min readSep 10, 2021

--

AWS Lambda function is heavily used everywhere due to its server less functionality.

Today we will try to create a sample Hello World Lambda function in python.

First login to AWS Console and search for AWS Lambda Service as below from Search Bar-

Find Lambda Function

Next Create a Lamba Function as below.

Create Lambda Function

For now we will go for most basic function and select the Hello World template -

Select Hello World Template for Lambda Function Creation

Give the details as below -

Name of the Lambda function -> hello-world-python3
Runtime -> Select Python 3.9
Permissions -> Select “Create New Role with Basic Lambda permissions” and press on “Create Function” button.

Lambda Function console will look like below

Lambda Console after creation of Lambda Function

Now we will modify the lambda code with below code snippet-

def lambda_handler(event, context):
if(event[“place”] == “Hill” ):
return “My Dear friend lambda takes you to Hill. Welcome to Hill Station”
if(event[“place”] == “Ocean” ):
return “My Dear friend lambda takes you to Ocean. Welcome to Ocean”
if(event[“place”] == “Desert” ):
return “My Dear friend lambda takes you to Desert. Welcome to Desert”
if(event[“place”] == “Home”):
return “My Dear friend lambda takes you to Home. Welcome Back to Home”

Lambda Function Code

Now configure test event for it as below -

Click on Configure Test Event

Set the value for testevent as below and click on Create Event button -

{
“name”: “Hill”
}

Now let us deploy the lambda function just clicking on Deploy Button.

Deploy Lambda
Lambda function Changes deployed

Now time to test by just pressing the test button above.

You reached the Hill with Lambda Function

Now once you are done with your experiment you can delete the lambda function from console.

Step 1: Delete Lambda function from Console.

Go to Function. Select the corresponding Lambda function you want to delete and delete the Function.

Delete Lambda Function

Step 2: Delete role for Lambda function from Console.

Delete Lambda Function Role

So with minimum effort we have run a python code using Lambda through AWS Console.

No setup of python runtime and installation of python in machine, we just use the AWS lambda server less infrastructure to run Lambda Function.

Happy Reading!! Happy Coding!!

--

--

Sanjit Khasnobis

I am passionate Data Architect/Engineer, computer programmer and problem Solver who believe presenting right data can make big difference in life for all.