tsmx / nodejs-lambda-tutorial

Tutorial for creating and deploying a Lambda function on AWS with Node.js (ESM)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating an AWS Lambda function with Node.js

Tutorial for creating an AWS Lambda function in Node.js (ESM) and deploying it with pure code upload or a Docker-image using the AWS CLI.

Prerequisites

To follow along the tutorial you'll need up & running...

  • Node.js >= v14, version 18 LTS or higher recommended
  • AWS CLI v2, see the getting started guide
  • Docker, v20.10 was used here

The Lambda function

The function itself is defined in index.js and called handler in the AWS Lambda terminology..

export const handler = async (event, context) => {
  console.log('EVENT: \n' + JSON.stringify(event, null, 2));
  return { info: 'Hello from AWS Lambda!' };
};

As per definition, any Lambda function will receive an event which is a JSON object passed by the invoker and a context object passed by Lambda itself. See here for details about the context.

More information coming soon...

About

Tutorial for creating and deploying a Lambda function on AWS with Node.js (ESM)


Languages

Language:JavaScript 77.5%Language:Dockerfile 22.5%