Understanding AWS Lambda Function | Day 17

Introduction

AWS lambda is the compute service just like ec2 that will let our application run without managing the servers. Lambda is AWS's serverless computing platform.

About

Lambda will set up all the required administration work like setting up the servers, auto-scaling, operating system maintenance, monitoring, and logging. Lambda is event-driven which means it will use its computing power when the event is driven and will not perform when there is not any event.

This means that the Lambda function can be used instead of ec2 in scenarios where we need to scale up rapidly in some time and scale down to zero in some time. The lambda function is used in serverless architecture.

Lambda functions are triggered by various AWS services and events, such as API Gateway requests, S3 bucket changes, database updates, and more which makes the lambda function powerful when used along with other AWS services.

We can use a simple file processing application where the S3 bucket will trigger the lambda function whenever the Upload or other file processing activities occur and that application can use the computing power of the lambda function and we can watch it using Cloud Watch.

In the EC2 instance, we can get the public as well as private IP address but in the case of the lambda function we do not have the knowledge about the IP address and where is it being hosted.

The lambda function is used in cost estimation where we can run the function to check the condition of the resources we have been using, we can set the schedule to trigger the lambda function using the cloud watch and in this way, we can run the lambda function without concerning about the cost.

The lambda function also helps in the security of the application as we can monitor whether the resources are being used or started as per the secure parameter of the organization or not. As DevOps Engineers we can use the Lambda function in various regular uses.

The serverless architecture calls the lambdahandler function first which takes the two parameters event and context. We can use other functions also but it have to be invoked or called from the lambdahandler function.

-: Below Point is Copied from the AWS Docs For Reference Purposes.

💡
The function handler takes two arguments, event and context. An event in Lambda is a JSON-formatted document that contains data for your function to process. The second argument your function takes is context. Lambda passes the context object to your function automatically. The context object contains information about the function invocation and execution environment.

This is a part of the 30-day AWS Journey and the implementation of the Lambda Function and how it helps in Cost optimization, we will look into the practical section in our next Article. [Project On Cloud Optimization Here ]