Creating and Deploying Lambda Functions.

Pascal Ogada
3 min readFeb 5, 2024

--

Lambda is a serverless compute service which is basically a method where backend services are provided as per need or demand basis. And it auto-scale depending on the amount of traffic you have.

With Lambda, you can bring your own code and you don’t need to worry about provisioning, maintaining or waiting for service to be built.

Lambda Function- function is a part of Lambda that contains the actual programming code.

We will practice how to create a code and test its function.

Lets create a basic lambda function. There are two types of deployment for lambda function, you can use a zip file as a deployment method or containers. zip file is important if you have a lot of dependencies that needs to be there for a Python to work.

I wrote a simple python deployment code and zipped it.

I then created a Lambda function. Below also you can see my code and a vital part of this code is my function handler. This is important to make the code work with lambda. It contains the event object which gives the event source an opportunity to pass information onto the Lambda function and context object which is generated by AWS and includes information specific to the runtime environment.

To specify the role, I went to my IAM and created a role with an inline policy.

From the console, you can see that my Lambda Function was created.

I went into the function and here is the code that I deployed.

To test the code I went to the Test environment, created my test event and saved my changes as shown below

I executed my function and it was successful.

In lambda, you only incur charges when lambda functions are actually running. One of the ways Lambda is charged is based on number of requests and these requests begin each time it starts executing the function in response to an event trigger.

Thank you for the read!

--

--