Search⌘ K
AI Features

Lambda Function: Configuration

Understand how to configure AWS Lambda functions by setting environment variables in serverless.yml for dynamic access to DynamoDB table names. Learn to assign least privilege IAM roles allowing specific DynamoDB actions to secure function permissions, enabling effective integration and deployment.

We'll cover the following...

We've created the DynamoDB table to store the inventory information. We also have the logic for the Lambda handler. Now, let's add the Lambda function to our serverless.yml.

import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";

export const hello = async (
  event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
  return {
    statusCode: 200,
    body: JSON.stringify({
      message: "Welcome to the Sweet Factory!",
      input: event,
    }),
  };
};
Project

In the code below, in our hello function (within the functions section), we'll add ...