How to Run “Hello World” on AWS Lambda in 5 Minutes

Run hello world on aws lambda

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.

To give you a bit of background- AWS lambda is the core of Serverless Computing at AWS and trust me it’s cool !!!. You can learn more about lambda here.

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.

Prerequisite

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.

Initial lambda console
Console If you have never created any lambda function

For me, it looks like the below because I have already worked on lambda many times.

AWS Lambda using Java Console

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.

run a hello world lambda

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.

Run hello world lambda in 5 minutes

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

lambda basic details screen

If you scroll down to the function code, you will see below code generated for the lambda

Run "Hello World" on AWS 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.

Lambda created successfully

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)

Configure test event

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.

Successful node lambda execution

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

Lambda delete node

And Hey lambda is deleted as you can see.

Conclusion:

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-

Please please share your feedback and help us get better with time 🙂

Also Read:

Leave a Reply

Your email address will not be published. Required fields are marked *