How to Run “Hello World” on AWS Lambda in 5 Minutes
In this quick tutorial, You’ll learn to run “Hello World” on AWS Lambda using the AWS management console. Additionally, you’ll learn to create a test event and invoke the lambda manually.
Basically Lambda let’s you run code without provisioning/managing any servers.
Suggested Read: Serverless Services on AWS- Complete List with Explanation
After completing this tutorial, you should be able to run your first “Hello World” on AWS lambda.
Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.
- AWS Account: See How to Setup AWS Free Tier Account in Right Way
- Basic Knowledge of Node.js or Python
Note: This post shows you how to quickly create a lambda function using Node.js and AWS Console. If you want to go the automated way and use AWS SAM, see How to Build a Node.js Application using AWS SAM.
Step 1: Open Lambda Console
In order to start with Lambda, You need to log in to AWS Management Console.
Once you are logged into AWS Console. Click on Services and search Lambda. Click on that. It will open the lambda console.
This is what it looks like if you have never created any lambda.
For me, it looks like the below because I have already worked on lambda many times.
But in any of the cases, All you need is to Click on Create Function.
Step 2: Create a Function
Click on Create function
There are three different options displayed here. However, we will choose “use a blueprint” option as you can see below screenshot.
In the blueprint search box, type hello-world and you will get two blueprints for hello-world. One in Python and another in Node.js. Select whichever you want and click on configure.
For this tutorial, I am selecting node.js but feel free to choose Python if you wish.
Once you click on configure, A screen to fill up basic detail will come up. Fill up the function name below, and for the role, keep create a new role as selected and scroll down
If you scroll down to the function code, you will see below code generated for the lambda
This function simply logs event data and returns something called key1. You will understand this key1 better when we configure the event later.
Scroll down and click on Create function.
Within a few seconds, you will see a message on the screen as successfully created.
Step 3: Configure a Test Event
As you might be knowing, lambda runs in response to events.
We have our function created. So let’s configure an event to invoke this.
Click on Select a test event and then select Configure Test Event
A window like below pops up where you can enter event details.
Put an event name as helloworld and change key1 to “Hello World!!!” as mentioned below. (The same key1 will be returned by the lambda as you saw earlier in the code as output)
Once done, Click Create
Step 4: Test your Lambda Function
Now when you have an event ready as well to invoke a lambda. click on test and wait for the magic to happen 🙂
On successful execution, you will see Hello World!!! on the screen as you can see below.
Congratulation!!! You ran your first lambda function successfully
Feel free to play with different tabs and options on the screen. And once learning of the day is done. head to step 5 to delete the lambda function
Step 5: Delete your Lambda Function
Now we are done playing with lambda so let’s delete it.
Click on Actions drop-down -> Click Delete function
And Hey lambda is deleted as you can see.
In this quick article, we created an AWS lambda function using Node.js. We configured a test event and invoked our lambda manually from the console.
In short, we were able to run “Hello World” on AWS Lambda pretty quickly.
You can also check out my previous post on lambda: how to create a lambda function using java
Enjoyed the content?
Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.
Don’t forget to motivate me by-
- Adding a comment on this post on what you liked and what can be improved.
- Follow Cloudkatha on –
- Share this post with your friends and colleagues
Please please share your feedback and help us get better with time 🙂
- Most Common Cyber attacks You should Know
- Basics Of Cyber Security for Beginners
- Create DynamoDB Table Using CloudFormation
- Create S3 Bucket using CloudFormation
- Things You Should Know about AWS SQS Dead Letter Queue
- S3 Bucket Creation using Terraform
- How to Create a Security Group in AWS using CloudFormation
- How to Install Git on Amazon Linux 2023