Home » AWS Creating a Lambda

AWS Creating a Lambda


How to create a Lambda function

  • Sign in to the AWS Management Console.
  • Click on the Lambda service.
  • Select the Northern Virginia region as it contains almost all AWS resources.
  • Click on the Function appearing on the left side of the console.

Creating a Lambda

The above screen shows that it does not contain any function.

  • Click on the Create function to create a new function.

Creating a Lambda

From the above screen, we observe that we have three ways of the authoring Lambda function, i.e., Author from scratch, Blueprints, and AWS Serverless.

  • Now, we create the Lambda function by using the Author from scratch.

Creating a Lambda
Creating a Lambda

Name: It defines the name of the Lambda function.

Runtime: You can select an appropriate Lambda runtime or create your runtime as a part of your function deployment package.

Role: You can create a new role. I created a new role, and my role name is MyLambdaRole.

Policy templates: It defines the Lambda basic execution role. I select a Simple microservice permission that provides you permission to execute your Lambda function.

  • Click on the Create function.

Creating a Lambda

The above screen shows that the function has been successfully created.

  • You can configure triggers appearing on the left side of the console.

Let’s see a scenario of Lambda function by using API Gateway.

Creating a Lambda

  • A user is browsing in google chrome and sends an HTTP request to API Gateway. An API Gateway, in turn, triggers the Lambda function, Lambda function then generates a response and sends back to the API Gateway. API Gateway further sends the response back to the user.
  • We know that the Lambda function scales out automatically. If two users are sending the HTTPS request to the API Gateway, two Lambda functions are invoked that serves the request individually.

Note: Node.js, python, java, and C# are the languages supported by Lambda.

How is Lambda Priced?

Lambda is priced in the following ways:

  • Number of Requests: It is priced based on the number of requests. First 1 million requests are free. $0.20 per 1 million requests thereafter.
  • Duration: Duration is calculated from the time your code begins executing until it returns or otherwise terminates rounded up to the nearest 100ms. The price depends on the amount of money you allocate to your function. You are charged $0.00001667 for every GB-second used.

Why is Lambda cool?

  • No Servers: You do not need to run your own server, Lambda will do everything for you. You just need to focus on your code.
  • Continuous scaling: Lambda will automatically scale up or scale out.
  • Super super super cheap: It is very cheap as you do not require a server.

Next TopicCloudWatch EC2

You may also like