Amazon DocumentDB to AWS Lambda Event Source Mapping

Amazon DocumentDB → AWS Lambda

Configure an AWS Lambda function to process events in an Amazon DocumentDB (with MongoDB compatibility) change stream

This pattern creates an Amazon DocumentDB Cluster along with an AWS Lambda Function in the supplied VPC configurations. An Event Source Mapping (ESM) is created that will help Lambda to process the events from a Change Stream in DocumentDB.
In this tutorial, we will be creating a database 'docdbdemo' and a collection 'products'. We will be tracking changes to this 'products' collection and activate Change Streams here.
Whenever a record in the 'products' collection updates, the Lambda will receive an event and invoke the Lambda function. This function will print the event received from ESM in its CloudWatch logs.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/docdb-lambda-nodejs-sam

Deploy

sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

sam delete

Created by:

Nikit Penkar

Nikit Penkar

Cloud Support Engineer at AWS

Follow on LinkedIn