sajad torkamani

In a nutshell

AWS Lambda lets you run server-side code without worrying about server infrastructure. You write your code as a function that’s executed when some trigger occurs (e.g., HTTP request or a change in a DynamoDB table).

When creating a lambda (function), you specify a few options:

  • Runtime: the language of your function (e.g., Node.js, Go, Python)
  • Architecture: z86_64 or arm64
  • Permissions: specify what permissions the lambda will have (i.e., what other AWS resources can it access and what can it do with them).

Example lambda

Here’s an example Node.js lambda:

console.log('Loading function');

exports.handler = async (event) => {
    console.log('Received event:', JSON.stringify(event, null, 2));
    
    for (const { messageId, body } of event.Records) {
        console.log('SQS message %s: %j', messageId, body);
    }
    
    return `Successfully processed ${event.Records.length} messages.`;
};
AWS Lambda: What is AWS Lambda?

Triggering a lambda

You can configure a Lambda to be triggered in response to various events (e.g., HTTP request, S3 bucket upload, DynamoDB table change, new SQS message, etc.).

Triggering an AWS Lambda

Other notes

  • You can specify a container image that your function should run in.
Tagged: AWS