Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
AWS Lambda
How Does AWS Lambda Work?
Create a lambda function with console
Create the function
Invoke the function
To invoke a function
Clean Up
To delete a Lambda function:
To get rid of the log group:
To delete the execution role:
Pros and Cons of AWS Lambda
Frequently Asked Questions
What is AWS Lambda?
What languages is AWS Lambda compatible with?
What makes Lambda a time-saving approach?
Last Updated: Mar 27, 2024

AWS Lambda

Author Anju Jaiswal
0 upvote
Master Python: Predicting weather forecasts
Ashwin Goyal
Product Manager @


AWS Lambda is a computing platform supplied by Amazon as part of Amazon Web Services that allows developers and software organizations to run code without setting up and managing servers, often known as "serverless architecture." As a result, you don't have to bother launching AWS resources or managing them. Instead, you must upload the code to AWS Lambda, where it will execute.



                                                          Source - Link

AWS Lambda

AWS Lambda manages all compute resource administration, including server and operating system maintenance, capacity provisioning and automated scaling, code monitoring, and logging, and runs your code on a high-availability compute infrastructure.


AWS Lambda applications are built on the same pattern, enabling an event-driven architecture.


                                                         Source - Link

You can use AWS Lambda to run code for almost any form of application or backend service. Write your code in one of Lambda's supported languages.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job

How Does AWS Lambda Work?

The AWS Lambda example with the block diagram below demonstrates how AWS Lambda works in a few simple steps:

AWS Lambda block diagram

                                                       Source - Link

Step 1: Upload your AWS Lambda code in any language that AWS Lambda supports. AWS Lambda functions support various languages, including Java, Python, Go, and C#.

Step 2: AWS Lambda can be triggered using the AWS services.

Step 3: AWS Lambda assists you in uploading code and the event data that should be used to trigger it.

Step 4: When prompted by AWS services, executes AWS Lambda Code:

Step 5: AWS only costs you when the AWS lambda code runs, not if it doesn't.

Create a lambda function with console

You develop a Lambda function via the console to start the exercise. Lambda's default code is used in this function. For non-compiled languages, the Lambda console has a code editor that allows you to modify and test code quickly. To upload your Lambda function code, you'll need to make an archive deployment package for compiled languages.

Create the function

Step 1: Login into your AWS account and click on "Sign in to the Console."                                         

Step 2: Enter your login and password details.

Step 3: Select Lambda under "AWS Services" 


                                          Source - link                       

Step 4: Select options and click on the "Create Function" button

Function Type: Author from scratch

Name: lambdaBlog

Runtime: Node.js 10.x

Role: Choose an existing role / Create any custom rule

Existing Role: lambda_basic_execution

Step 5 Create Function button in AWS Lambda

                                                Source - link

Step 5: Now you will be able to see the below screen. Choose a way to upload/create code in the lambda function.                                              Step 6 upload or create code in lambda function

                                          Source - link

Step 6: Now, you can write your code in the editor provided. It runs on Nodejs, which we selected earlier.

Step 7:  Handler name should be the same as your function name. This way, AWS knows which function to execute.

Step 8: We can add more options like execution timeout, environment variables, tags to group out our other functions, memory, etc.     

   Step 9 Add more option

                                                     source - link

Step 19: Click "Save."           

Step 10: Now, copy the ARN number on the top right corner.         

Step 11 copy ARN no from top right as per below screen

                                                        Source - link

Invoke the function

Invoke your Lambda function using the sample event data provided in the console.

To invoke a function

  • After selecting your function, choose the Test tab.
  • Select New event from the Test event menu. Leave the default hello-world option in Template. Give this test a name and take note of the following sample event template:
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"


  • Choose test after saving your changes. Per function, each user can create up to ten test events. Other users cannot access those test events. Lambda executes your function for you. The example event is received and processed by the function handler.
  • Upon successful completion, view the results in the console. 
    → The status of the execution is shown as successful in the Execution result. Expand Details to see the outcomes of the function execution. The Log groups page in the CloudWatch interface is accessible via the logs link.
    → The Summary section shows the critical information reported in the Log output section (the REPORT line in the execution log).
    → Lambda's log for each invocation is displayed in the Log output section. These logs are written to CloudWatch by the function. These logs are displayed on the Lambda interface for your convenience. Go here to add logs to the CloudWatch log group and access the CloudWatch console's Log groups tab.
  • Run the function (select test) a couple more times to get some metrics for the following step
  • Select the Monitor option. This page displays graphs for the metrics sent to CloudWatch by Lambda.

Clean Up

Remove the example function once you've finished working with it. You can also remove the log group that contains the function's logs and the execution role that the console established.

To delete a Lambda function:

  1. Open the Functions page of the Lambda console.
  2. Choose a function.
  3. Choose Actions, Delete.
  4. Select Delete from the Delete function dialogue box.


To get rid of the log group:

  1. Open the CloudWatch console's Log groups page.
  2. Select the log group for the function (/aws/lambda/my-function).
  3. Select Actions, then Delete Log Group (s).
  4. Select Delete in the Delete log group(s) dialogue box.


To delete the execution role:

  1. Open the AWS Identity and Access Management (IAM) console's Roles page.
  2. Choose the function's function (my-function-role-31exxmpl).
  3. Select Delete Role.
  4. Select Yes, delete in the Delete role dialogue box.


With AWS CloudFormation and the AWS Command Line Interface, you can automate creating and cleanup functions, log groups, and roles (AWS CLI). See Lambda example applications for fully functional sample applications.

Pros and Cons of AWS Lambda

Frequently Asked Questions

What is AWS Lambda?

It's an Amazon Web Services serverless compute service that runs code in response to events and controls the compute resource autonomously.

What languages is AWS Lambda compatible with?

The languages supported by AWS Lambda are as follows: Python, Java, js, C#, Ruby, Go, and PowerShell.

What makes Lambda a time-saving approach?

There are specific reasons for this. The one is it's possible to store everything in the local server memory. Also, data can be stored directly in the database without affecting performance. In addition to this, testing is not much complicated. Integration testing can be made mighty through multiple vendors.


In this blog, we have given a detailed description of the AWS Lambda function, the complete steps of its working, the creation of the AWS Lambda function from the console, and the pros and cons in brief.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem DesignMachine learning and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!!

Previous article
AWS Elastic Beanstalk
Next article
AWS Lambda Foundations
Live masterclass