AWS Lambda is a server-less computing service that lets the developers run their code in the standard runtime environment of Lambda without having to worry about server handling with ZERO SUPERVISION. To develop any AWS cloud service or application creating a Lambda function is a must. Here we discuss how AWS Lambda function work and creating a Lambda function.
As defined by the AWS official source, "AWS Lambda is a compute service that lets you run code without provisioning or managing servers. It executes your code only when needed and scales automatically, from a few requests per day to thousands per second."
Developers can start using AWS Lambda services, either by uploading the code or coding directly in the Lambda’s code editor and mention the conditions triggers the code. The code executed on the lambda run time environment is called a lambda function. With this any event can prompt your function, without developers worrying about handling the server or getting the right type of application or resource. Meaning that businesses don’t have to pay when your code is not running, thereby saving on server costs.
Once an event triggers, Lambda runs associated code by picking resources to execute an event, by making use of the best resources available in the infrastructure ecosystem. Thereby enabling businesses to have intelligent management of IT infrastructure. The AWS Lambda run-time environment's control plane entity consists of APIs that facilitate AWS resources for the application execution. Another key aspect of run time environment is data pane, this provides APIs to run the functions. Whenever a function is called to run a function, data pane facilitates either a dedicated execution environment or uses the allotted one. This execution environment is never shared with other functions.
Figure: Workflow of AWS Lambda
Step 1: Login into your AWS account and click on “Sign in to the Console.”
Step 2: Enter your login ID and password.
Step 3: Select Lambda under "AWS Services"
Step 4: Click on “Create Function”
Step 5: Select options and click on “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 6: Now you will be able to see the below screen. Choose a way to upload/create code in the lambda function.
Step 7: Now you can write your code in the editor provided, it runs on Nodejs which we selected earlier.
Step 8: Handler name should be the same as your function name, this way AWS knows which function to execute.
Step 9: We can add more options like execution timeout, environment variables, tags to group out our other functions, memory etc.
Step 10: Click "Save."
Step 11: Now copy ARN number on the top right corner.