In this quick tutorial, You will learn to run “Hello World” on AWS Lambda using console. You will also learn to create 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.
- AWS Account
- Basic Knowledge of Node.js or Python
Step 1: Open Lambda Console
In order to start with Lambda, You need to login to AWS Management Console.
Once you are logged into AWS Console. Click on Services and search Lambda. Click on that. It will open lambda console.
This is how it looks like if you have never created any lambda.
For me it looks like below because I have already worked on lambda many a 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 option displayed here. However we will choose “use a blueprint” option as you can see in below screenshot.
In the blueprint search box, type hello-world and you will get two blueprint for hello world. One in python and another in Node.js . Select which ever 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. Fill up function name as below, and for role keep create a new role as selected and scroll down
If you scroll down to 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 event later.
Scroll down and click on create function.
Within few seconds you will see a message in 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 code as output)
Once done, Click Create
Step 4: Test your Lambda Function
Now when you have 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 in 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 console.
In short we were able to run “Hello World” on AWS Lambda.
You can also checkout 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 –
- Subscribe to our newsletter to get notified each time we post new content.
- Share this post with your friends and colleagues
Please please share your feedback and help us get better with time 🙂