
Few interesting things about me:
- Software Engineer @ JP Morgan Chase & Co.
- AWS Community Builder 2023
- I love working with technology
- I enjoy playing video games 😄
Search for a command to run...

Few interesting things about me:
If you’re new to machine learning, reinforcement learning, especially, then it’s completely okay to have a hard time understanding these fancy jargons in front of you. Here’s my attempt to simplify these while we work on a little robo-car :) About AW...

Dynamo DB is AWS's NoSQL offering in the vast set of managed databases as a service that they provide. Like most other services, it's fully serverless, flexible and easy to scale. The Data Model As we're working on NoSQL here, there's no real restric...

I was recently a part of a hackathon and was found searching for good Jupyter environments on the cloud to be able to work on my ML Project. Soon enough, I found myself here. However, it took me a while to figure out how powerful it truly can be. F...

I spend 5 days out of a week coding for work, so I'm definitely not motivated to code a lot on weekends. This means that I do not have any software development tools installed on my personal machine. Not even IDEs. However, being the curious little g...

Almost a week to this and not a lot of drama on Indian Twitter, so I thought I could write about it. TLDR: Malicious code with a backdoor was added to one of the core packages of Linux affecting almost all Debian and Redhat distros; was later discove...

Need to run code, build applications, provide services without worrying about infrastructure, management and scaling? Meets all the serverless criteria!
In this thread, let's talk about AWS Lambda and what it brings to the table with its capabilities and write our very first Python serverless function on AWS Lambda. But before that, let's get some ground-level understanding of Serverless.
Confusing as it might sound, Serverless is not 'code running without a server' but more like 'code not running on your server'.
You would need a server to host your code on the internet. Imagine you host a social media application on your local server. As your application becomes more and more popular, you have more users, which means more interactions and more traffic. Naturally, you'd need a beefier machine to handle all operations without causing trouble to the users. Having more users also means that you'd need more storage to store all the data, viz. user information, media, etc.
But what if someone else could automatically handle the issues of resources, speed, etc. without us having to keep manually managing the infrastructure? That's exactly what Serverless brings to the table.
Serverless computing is a cloud computing execution model in which the cloud provider allocates machine resources on-demand, taking care of the servers on behalf of their customers.
Serverless functions are programmatic functions we write in our favourite programming languages, except the execution, scaling and management is taken care of by Serverless infrastructure.
Serverless functions are event-driven and scaled on-demand, hence they make for a lot of use-cases like hosting Web applications, IoT, Streams and Batch Processing, Cloud Automation, etc.
AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS). We can create functions or complete applications written in one of the supported languages and upload them to AWS Lambda. Once deployed, AWS can take care of managing your code on the server-side.
The AWS Free Tier offers 1 Million Free Requests per month for AWS Lambda. Let's hop into the AWS Console and try it for ourselves!
Open up the AWS Console and search for Lambda.
Click on Create Function.
With other default settings, choose a function name and runtime environment, I'll go with Python 3.9 for this thread.
The function has successfully been created and now you are at the Dashboard for this function. The Function overview gives an idea of what Lambda is connected to. Lambda Functions can work independently or can be connected with other AWS Services.

You can use the provided code editor to make changes to your function. You can also create new files in the file system and even upload files.
Serverless functions, as I previously mentioned are event-driven. You can see that the function is associated with an event. The parameter event here is a Python Dictionary, which is a collection of key-value pairs, that provides information about a certain event.
Let's just print this event.
When you click on Test, it asks you to create a test event. Just give it a name and leave everything as-is. Then, click on Deploy to apply these changes and then click on Test.
You can see that we get the same key-value pairs present in the test config under Execution Results.
Let's use the data in the event parameter to modify our response. Click on the dropdown near Test and change the test configuration. Update the key-value pairs, to say use your name.
Similarly, we can update our function to print the name in the response. If there is no name in our event, we'll simply return 'No Name'.
import json
def lambda_handler(event, context):
# TODO implement
res = {
'name': event['name'] if 'name' in event else 'No Name'
}
return {
'statusCode': 200,
'body': json.dumps(res)
}
You can deploy and test your function to see the results.
Once you're done exploring Lambda, you can delete your Lambda function so that you're not billed for it in the future. Even though you won't be charged until you exceed the request limits for the function, it's recommended to delete or terminate services you are not using.
Congratulations, you just created your first AWS Lambda function! I hope you enjoyed working in the serverless world. This was just an introduction to the capabilities of Lambda, the possibilities with it in real life are endless.
Thank you for reading :)