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.
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 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...