Menu
Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

Step 2: Create a Lambda Function

In this step, you will create a very simple AWS Lambda function to read stream records and echo their contents to Amazon CloudWatch Logs. You will associate this Lambda function with the stream on the DynamoDB table that you created in Step 1, so that changes to data in that table will trigger the Lambda function.

  1. Open the DynamoDB console at https://console.aws.amazon.com/dynamodb/.

  2. In the navigation pane, choose Tables.

  3. In the list of tables, choose StreamsLambdaTable.

  4. Choose the Triggers tab.

  5. Choose Create trigger, and then choose New function. The AWS Lambda console appears.

  6. In the Configure event sources section of the Lambda console, in the DynamoDB table field, choose StreamsLambdaTable.

  7. Choose Next

  8. In the Configure function section of the Lambda console, do the following:

    • In the Name field, type StreamsLambdaFunction. (This is the name of the function that we will use for this walkthrough.)

    • Leave the Runtime field at its default setting: Node.js .

    Do not modify any fields in the Lambda function code section. You will use the pre-provided Node.js code.

  9. In the Lambda function handler and role section, do the following:

    • Leave the Handler field at its default setting: index.handler.

    • In the Role field, select DynamoDB event stream role. A new window appears, asking for confirmation that you want to create a new IAM role, lambda_dynamo_streams, that will be used when invoking your Lambda function. Choose Allow to create the role and dismiss the window.

    • Back in the Lambda console, leave all of the other settings on the page at their default values, and choose Next.

  10. On the Review page, go to Enable event source and choose Enable now.

    Leave all of the other settings on this page their default values, and then choose Create function.

Step 3: Generate Activity in the DynamoDB Table