Skip to content
Related Articles

Related Articles

Amazon Web Services – Creating a Lambda Function

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 21 Nov, 2022
Improve Article
Save Article

AWS Lambda is one of the compute service that helps you to run code without provisioning or managing resources servers. With lambda, user can runs their code on a high-availability computing infrastructure. Lambda performs all the tasks related to administration of the compute resources, which includes the servers and operating system maintenance, automatic scaling, and logging. It also facilitates automatic scaling. With the help of Lambda, users can run their code for virtually having any type of application or backend service. Lambda supports many programming languages, all you need to do is supply in your code. Users can organize their code into Lambda functions. and these Lambda functions will runs your function only once you needed and then automatically scales, and there is very good option of servicing from a few requests per day to thousands per second. Only you need to  pay for the compute time that your code will take to run as there is no charge for the lambda function code when your code is not running. But when you are using Lambda,  you are the only responsible for your code. Lambda will automatically manages memory, CPU, network and other resources need to run your code.

AWS Lambda is a computing service provided by AWS that will make sure that your Lambda function will be executed only when it is triggered or when it is needed and it also automatically scales your lambda function for thousands of requests per second. You can attach the events of other AWS services such as creating or updating Dynamo DB tables, uploading files to S3 Bucket, hitting HTTP method endpoints, and so on to your Lambda function and trigger when that event occurs.

Creating  Basic Lambda Function

Let us create your lambda function in step by step manner

Step 1: Log in to your AWS account. Once you are redirected to the AWS management console. Click on the Search bar and Search for Lambda. Select the Lambda option in the list.


Step 2: In a while, you will be directed to the AWS lambda dashboard page and there you can find create function option click on it.


Step 3: You will then land on the page which is shown below. There are several options available for creating functions such as Author from Scratch where the created function will have hello world code or Use a blueprint option where you can use available functions code and other options named Container Image, Browse serverless app repository.


Step 4: Choose Author from Scratch option among the available options. In the Basic information section, you can give any function name for your lambda function. We are giving the name “myFunction”. Next, choose your runtime environment, we are leaving it as the default option “Nodejs 14. x”.

Step 5: In the permissions section you can notice the change default execution role option. Click on it to expand and view the options. you can see various options there as shown in the figure below.

Step 6: You can create a lambda function with a custom role that exists already using the “Use an existing role” option. Using the “Create a new role from AWS policy templates” option you can create a new role by giving the role name and selecting the policy templates and doing so creates a new role and gives that role to lambda function while creating the function.

Step 7: You can select “Create a new role with basic Lambda permissions” and click on the “create function” option.


Step 8: In a while, your Lambda function will be created and you will land on your Lambda function and it will look like below. you can see the lambda function code which returns a response of “Hello from Lambda”  below in the Code source section.

Step 9: You can add the Events of other AWS services which should trigger this lambda function by clicking the “Add trigger” option in the Function overview section as shown in the below figure.


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!