codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
☁️

AWS Cloud

19 / 60 topics
18Introduction to AWS Lambda19Creating a Lambda Function20Lambda Triggers
Tutorials/AWS Cloud/Creating a Lambda Function
☁️AWS Cloud

Creating a Lambda Function

Updated 2026-05-15
10 min read

Creating a Lambda Function

Introduction

AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers. You pay only for the compute time you consume, and there's no need to worry about scaling your application up or down. In this tutorial, we'll walk through the steps to create and configure a basic AWS Lambda function using the AWS Management Console.

Concept

AWS Lambda allows you to run code in response to events such as HTTP requests, changes in data, or scheduled tasks. You can write your functions in several languages including Node.js, Python, Java, Go, C#, PowerShell, and Ruby. The function is executed by AWS Lambda when the event occurs, and you only pay for the compute time used.

Examples

Step 1: Create a Lambda Function

  1. Log in to the AWS Management Console:

    • Open your web browser and go to the AWS Management Console.
    • Enter your credentials to log in.
  2. Navigate to Lambda:

    • In the AWS Management Console, search for "Lambda" in the services list and click on it.
  3. Create a Function:

    • Click on the "Create function" button.
    • Choose "Author from scratch".
    • Enter a name for your function (e.g., MyFirstFunction).
    • Select a runtime (e.g., Python 3.x, Node.js 14.x).
    • Choose an execution role. You can either use an existing role with the necessary permissions or create a new one.
      • If creating a new role, select "Create a new role with basic Lambda permissions".
    • Click on "Create function".

Step 2: Write and Test Your Function Code

  1. Edit the Function Code:

    • In the Lambda console, you'll see the code editor where you can write your function.

    • For example, if you selected Python as the runtime, you might have a basic skeleton like this:

      Python
      1def lambda_handler(event, context):
      2 return {
      3 'statusCode': 200,
      4 'body': json.dumps('Hello from Lambda!')
      5 }
    • If you selected Node.js, the code might look like this:

      JavaScript
      1exports.handler = async (event) => {
      2 return {
      3 statusCode: 200,
      4 body: JSON.stringify('Hello from Lambda!'),
      5 };
      6};
  2. Test Your Function:

    • Click on the "Test" button to create a test event.
    • Enter a name for your test (e.g., MyFirstTest).
    • Optionally, you can configure the input data for the test.
    • Click on "Create".
    • Now, click on the "Test" button again to run the function with the created test event.

Step 3: Configure Function Settings

  1. Set Environment Variables:

    • Go to the "Configuration" tab and select "Environment variables".
    • You can add key-value pairs here that your function can access at runtime.
  2. Configure Memory and Timeout:

    • Still in the "Configuration" tab, you can adjust the memory allocation and timeout settings for your function.

Step 4: Deploy Your Function

  1. Deploy Changes:
    • After making any changes to your function code or configuration, AWS Lambda automatically deploys them.
    • You don't need to manually deploy; just save your changes in the console.

What's Next?

Now that you've created and configured a basic AWS Lambda function, you can explore how to trigger it with different events. For example, you can set up an API Gateway to invoke your Lambda function via HTTP requests or configure S3 bucket events to trigger your function when files are uploaded.

AWS Lambda offers a wide range of features and integrations that can help you build powerful serverless applications. Continue exploring the AWS documentation and resources to learn more about advanced configurations and best practices for using AWS Lambda in your projects.


PreviousIntroduction to AWS LambdaNext Lambda Triggers

Recommended Gear

Introduction to AWS LambdaLambda Triggers