Skip to main content

Command Palette

Search for a command to run...

AWS Day 33: Create a Lambda Function | KodeKloud 100 Days of Cloud

Updated
4 min readView as Markdown
AWS Day 33: Create a Lambda Function | KodeKloud 100 Days of Cloud
A

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops

Introduction

As cloud applications continue to evolve, serverless computing has become one of the most popular ways to build scalable applications without managing servers. Instead of provisioning EC2 instances or maintaining infrastructure, developers can focus entirely on writing code while AWS automatically handles execution, scaling, availability, and maintenance.

During Day 33 of the KodeKloud 100 Days of Cloud Challenge, I explored AWS Lambda, one of AWS's core serverless services.

The objective of this lab was simple but practical—create a Python Lambda function that returns a custom greeting with an HTTP status code of 200, while using a dedicated IAM execution role.

Although this example is small, it introduces the basic workflow you'll use when building serverless applications on AWS.

What is AWS Lambda?

AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers.

You simply upload your code, configure the runtime, and AWS automatically executes your function whenever it is triggered by an event.

Some common Lambda use cases include:

  • REST APIs with API Gateway

  • Processing files uploaded to Amazon S3

  • Scheduled automation using EventBridge

  • Infrastructure automation

  • Real-time event processing

  • Backend services for web and mobile applications

One of Lambda's biggest advantages is its pay-as-you-go pricing, where you only pay for the time your code actually runs.

Lab Objective

The goal of this hands-on lab was to:

  • Create a Lambda function named devops-lambda

  • Use the Python runtime

  • Create an IAM role named lambda_execution_role

  • Attach the IAM role to the Lambda function

  • Deploy the function successfully

  • Return an HTTP status code 200

  • Display the message:

Welcome to KKE AWS Labs!

Step 1: Create the Lambda Function

I started by opening the AWS Lambda Console and selecting Author from scratch.

The function was configured with the following details:

Setting Value
Function Name devops-lambda
Runtime Python 3.10
Architecture x86_64 (Default)

Instead of using the default execution role, I selected Custom execution role because the lab required a dedicated IAM role.

Step 2: Create the IAM Execution Role

Next, I created a new IAM role named:

lambda_execution_role

The role automatically included the AWSLambdaBasicExecutionRole managed policy.

This policy allows the Lambda function to write execution logs to Amazon CloudWatch Logs, which is essential for monitoring and debugging.

Using a dedicated IAM role also follows AWS security best practices by granting only the permissions required for the function.

Step 3: Write the Python Function

After the Lambda function was created successfully, I replaced the default code with the following Python function:

This simple function returns:

  • HTTP Status Code: 200

  • Response Body: Welcome to KKE AWS Labs!

Once the code was updated, I clicked Deploy to publish the latest version.

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": "Welcome to KKE AWS Labs!"
    }

Step 4: Test the Lambda Function

To verify everything was working correctly, I created a new Test Event inside the Lambda console and invoked the function.

The execution completed successfully and returned the following response:

{
  "statusCode": 200,
  "body": "Welcome to KKE AWS Labs!"
}

What I Learned

Although this lab involved a simple Python function, it helped me understand several important AWS concepts.

Some key takeaways include:

  • How AWS Lambda enables serverless application development.

  • Why IAM execution roles are required for secure access to AWS services.

  • How to deploy Python code directly from the AWS Management Console.

  • How to test Lambda functions using built-in test events.

  • How Lambda automatically manages scaling and infrastructure.

This hands-on exercise provided a solid foundation for building more advanced serverless applications in the future.

Conclusion

Day 33 was my first practical experience working with AWS Lambda, and it demonstrated how quickly serverless applications can be developed and deployed.

By creating a Lambda function, configuring a custom IAM execution role, deploying Python code, and testing the function successfully, I gained a better understanding of how AWS simplifies application development without requiring server management.

This lab serves as an excellent introduction to the AWS serverless ecosystem and prepares the way for integrating Lambda with services such as Amazon API Gateway, Amazon S3, Amazon DynamoDB, Amazon EventBridge, and Amazon CloudWatch.

100 Days Of Cloud (AWS)

Part 2 of 28

This series documents my 100 Days of Cloud journey with AWS using KodeKloud. Each blog covers one daily task with hands-on practice, simple explanations, and real learning for beginners and cloud aspirants.

Up next

AWS Day 31: Configuring a Private RDS Instance for Application Development

Introduction During Day 31 of the KodeKloud 100 Days of Cloud Challenge, I worked with Amazon RDS (Relational Database Service) by provisioning a private MySQL database instance. In many production en

More from this blog

A

Anand Raval

130 posts

I'm Anand Raval, a Cloud & DevOps Engineer with AWS Solutions Architect Associate (SAA-C03), Certified Kubernetes Administrator (CKA), and Azure Fundamentals (AZ-900) certifications. This blog covers AWS, Kubernetes, Terraform, CI/CD, cloud architecture, automation, cost optimization, troubleshooting guides, and hands-on DevOps projects.