How to Use DynamoDB Streams to Trigger a Lambda Function on Data Changes
You have a DynamoDB table and you need to react to every write — inserts, updates, deletes — without polling or building a change-detection layer yourself. DynamoDB Streams with Lambda as an event source is the standard pattern for this, but the wiring has enough moving parts that it's easy to get the IAM wrong, pick the wrong stream view type, or misconfigure the event source mapping and wonder why your function never fires. TL;DR: DynamoDB Streams + Lambda Event Source Mapping Step What You're Doing Key Decision 1 Enable Streams on the table Choose StreamViewType (NEW_IMAGE is the most common) 2 Grant Lambda permission to read the stream Attach AWSLambdaDynamoDBExecutionRole or equivalent custom policy 3 Create the Event Source Mapping Set StartingPosition, BatchSize, and bisect-on-error behavior 4 Validate end-to-end Write a test item, check CloudWatch Logs for invocation How DynamoDB Str...