Creating a Lambda function

The first step of creating a lambda function is choosing a supported programming language and write the method. Amazon Lambda supports natively

  1. Java
  2. Go
  3. Node.js
  4. C#
  5. Python
  6. Ruby
  7. PowerShell

In our case we will use Node/Javascript for the source code.

You can find the example application at https://github.com/codefresh-contrib/aws-workshop-demos/tree/main/lambda/aws_lambda_functions/simple.

Our lambda function is very simple:

module.exports.handler = async (event) => {
    console.log('Event: ', event);
    let responseMessage = 'Hello World from AWS Lambda';
  
    return {
      statusCode: 200,
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        message: responseMessage,
      }),
    }
  }

This is a very simple method that just prints a message when it is called.