AWS Lambda for New Beginner


When you develop apps, you want them to bring the best user experience. To make magic happen, your app needs a background code that runs in response to events.
But managing the backend hosting and creating backend code requires you to size, provide, and measure multiple servers, manage app updates, use security clips and monitor all of this infrastructure for performance and availability.
Wouldn’t it be nice if you could focus on building better projects without worrying about their infrastructure? That’s where the AWS Lambda comes into play.

What is AWS Lambda?

AWS Lambda is a seamless computer service that allows you to use your code without having to worry about being assigned or managing any server. You can run your own application or back-up service using AWS Lambda with zero administration. Just upload your code to Lambda, and it will use your code, or measure the infrastructure with high availability.
The code you use in AWS Lambda is called the lambda function. Currently, it supports the following programming languages:
1. Java
2. Python
3. C #
4. Node
5. Go
6. PowerShell
7. Ruby

AWS Lambda Features

Below are some of the key features offered by AWS Lambda:
* AWS Lambda easily scopes structure without additional config. It also reduces the workload involved.
* It offers many options such as AWS S3, CloudWatch, DynamoDB, API Gateway, Kinesis, CodeCommit, and many more to start the event.
* You do not need to invest up front. It only pays for the memory used by the lambda function and costs less than the number of applications which is why it costs money.
* AWS Lambda is secure. It uses AWS IAM to define all roles and security policies.
* Provides error tolerance for both coding and operational services. You don’t have to panic about the base line.

How AWS Lambda Works?

  • You then write your code in the lambda editor or upload it in the language of the supported program to the Zip file.
  • Once the lambda code is loaded, the service manages all volume measurements, integration, and infrastructure management.
  • In order to use code, you need to start lambda work with the external AWS service, which may request lambda function. For example, it could be a bucket of S3.
  • In a few seconds, the lambda will be ready to start your work automatically when the event takes place.
  • AWS Lambda uses your code when a trigger event is called. Provides control over and monitors your servers.
  • If your work requires a lot of processing power, you will choose a model that has a lot of processing power and RAM, or if your lambda code only works for two seconds, it will choose the lowest model, which saves you money and time.

Creating AWS Lambda Function

I will create a simple game using the lambda function on Node.js for this article. I will create a lambda function of rolling dice, generating a random number between 1 and 6, and printing it.

  • You also need to select a role play. Since I do not have an existing role defined in my AWS account, I will continue to choose to create a new role option. Click on Create Function.
  • Use the code states below in the editor. You can also upload the code with the help of the zip file, but I am using the internal AWS code editor. Follow me.
exports.handler = async(event)=> 
const minimum = 1;
const maximum = 6;
const randomNumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
const output = 'Dice throw result is: ' + randomNumber;
return output;



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store