What in the cloud does a Lambda function do?

Until this past week, my biggest question about AWS was, "What does a Lambda function actually do?"

Turns out, it can do just about anything you want. Essentially, it's a serverless computing service that allows us to create a function to perform any desired task, run it as many times as needed, and in any way we see fit. AWS makes this possible for us because it takes care of the hassle of the infrastructure and lets us focus on writing and deploying the code, which is why it’s called serverless.

As a backend developer in my current project, my initial task was to create a POST API for the front end to utilize.

To accomplish this, I developed a Python-based Lambda function that receives information from the front end and subsequently stores it in a Postgres database. Whenever the API endpoint is accessed in the browser, it triggers the execution of the Lambda function.

Understanding that last sentence took me quite some time.

Here's how I perceive it: the Lambda function is event-driven and can’t do anything on its own, so it needs to be connected to another service. In this case, we connect it to the API Gateway. The API Gateway serves as the entry point of our application. Naturally, this endpoint must perform some action for us, correct? In this case, the endpoint relates to a POST request. All the necessary actions associated with our POST request take place within the Lambda function. So, when we create our endpoint, we link it to the Lambda function. Consequently, whenever the front end sends a POST request to the endpoint, it prompts the Lambda function to execute. Thus, the function accepts the information and proceeds to process it.

In conclusion, AWS Lambda is a computing service that is event-driven, where you can store code that needs to be triggered by another service within AWS, such as the API Gateway.