Back to Blog Home

Everything You Need To Know About AWS Lambda and "Hello World" Tutorial

Deepak Rohatgi| Serverless | 7 months, 1 week



 

One of the hardest part of building, deploying and maintaining a cloud application is the provisioning and managing servers.

 

Administering your servers to make your code runs smoothly is not really fun and distracts you from what you really do best — which is to write code and make products which solves real customer issues. 

 

This is where AWS Lambda comes into the picture which lets you focus on building your app while it takes care of entire administration of sever auto magically. 

 

The best part about all Lambda is that you don’t have to pay for entire time you rent a virtual machine, but simply paying for only the time your app runs or computes. 

 

It is also language independent, so you can write your service or app in any language you like and just upload it to lambda, it will then do all the heavy lifting without you even have to worry about it. 

 

Lets face it, if your app begins to scale, then the problems with making there service available without downtime becomes really crucial and the process of making your app scale is not really one filled with fun. With lamda you don’t have to really do the rocket science yourself as it handles it all behind the scene. 

 

You can call your function with a simple call from any mobile or web app or use it in conjunction with other AWS services. Whenever you trigger an event, AWS just takes milliseconds to spin up instance of your function. 

 

Unlike other AWS services, Amazon charges AWS Lambda with increments of 100 milliseconds. 

 

It is part of a new paradigm of cloud architecture called serverless computing. Serverless doesn’t mean there is no server, it just means that work of managing and scaling a server is abstracted away from the user. These ‘function-as-a-service’ platforms work by triggered events like webhooks, click of buttons or form submissions etc. 

 

Serverless is usually used for the overall software architecture where ‘function as a service’ is how the business logic gets implemented within the serverless architecture. 

 

FaaS is usually associated with 5 main characteristics : microservices, pay-per-execution, ecosystem, auto-scaling, event-driven.

 

Simple Hello World Example For AWS Lambda

 

1. Go to Lambda from AWS Console :

 

 

2. Then select AWS Lambda from the list of AWS services:

 

 

 

Click on “Get Started Now”

You will arrive at “Select Blueprint Screen” which gives you a list of predefined templates.

 

3. Select the ‘Hello World’ Template and add following code in the Lambda function code :

exports.handler = function(event, context) {
context.succeed(“Hello, World!”);
};

 

4. Select the basic execution role for the ‘Role’ dropdown which is below the code editor and click on Allow when it asks for permission.

 

Click on Next and ‘Create Function’

 

5. Now when you click on ‘Test’ button you will see the output : “Hello, World !”

 

 

 

Congratulations you just created your very first AWS Lambda function. 

 

 



Join 1000+ People Who Subscribe to Weekly Blog Updates

Back to Blog Home