Skip to content

Lambda

Creating a Lambda Function

  1. Open the AWS Management Console and sign in to your AWS account.
  2. Navigate to the Lambda service by clicking on the "Services" tab and selecting "Lambda".
  3. In the Lambda console, click on the "Create function" button.
  4. Select "Author from scratch".
  5. In the "Basic information" pane, for "Function name" enter myLambdaFunction.
  6. For "Runtime" choose "Node.js 20.x".
  7. For "Execution role" choose "New from scratch".
  8. In the "Permissions" pane, select the "AWS Lambda basic execution role" policy and click on "Choose".
  9. Click on "Create function".
  10. In the "Function code" pane, paste the following code:
JavaScript
exports.handler = async (event) => {
  return {
    statusCode: 200,
    body: JSON.stringify('Hello, World!')
  };
};
  1. Click on "Save".
  2. In the "Tester" pane, click on "Test".
  3. The results of the test will be displayed in the "Execution result" pane.

Publish Lambda

  1. Once tested and validated, you need to obtain an url to trigger this from anywhere
  2. Goto "Configuration" tab and select "Function URL"
  3. Click "Create Function URL"

lambda-url

  1. Select NONE to allow anyone with the link to access this function
  2. Click on the function URL and you will see the output of the function in browser Hello, World!

Released under the MIT License. Some of the contents are generated using Gen AI