Amazon EventBridge Custom Event Bus to Amazon DynamoDB

Amazon EventBridge Custom Bus → Amazon DynamoDB

Write events from an EventBridge Custom Event Bus directly to DynamoDB with PutItem or BatchWriteItem universal targets, with no Lambda in the path.

This pattern creates an Amazon EventBridge Custom Event Bus with two subscribers that write events to an Amazon DynamoDB table, with no Lambda function in the path. Each subscriber delivers to a universal target, a DynamoDB API action that EventBridge invokes directly, and a JSONata expression builds the request from the event.
Events are published with PutRawEvents and routed on the eventType metadata key. Events with eventType 'Order Placed' are written one at a time with PutItem. Events with eventType 'Order Imported' are collected into batches of up to 25 and written with a single BatchWriteItem call.
With the batch write, a duplicate ID in a batch or a throttled call fails the whole batch. EventBridge retries the batch and then writes one record to an Amazon SQS dead-letter queue listing the IDs of all events in it, so the dead-letter queue is essential for the batch subscriber.
This pattern deploys one EventBridge Custom Event Bus, two subscribers, one DynamoDB table, one SQS dead-letter queue, and one IAM role.

< 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/eventbridge-custom-bus-dynamodb/sam

Deploy

sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

From the pattern directory, delete the stack: sam delete.

Created by:

Marco Buss

Marco Buss

Sr. Solutions Architect at AWS

Follow on LinkedIn