Search code examples
amazon-dynamodbaws-lambdaamazon-dynamodb-streams

How to handle DynamoDB Global streams


Looking to create a DynamoDB global table for storing customer information. The problem I have is my current pattern is to listen to changes on this table and send email updates using Lambda triggers.

i.e. Your profile information was changed. If this was not you..

Do I now need to have that Lambda in each region and will data replication mean that it is triggered for each region?


Solution

  • I think you might have misunderstood with streams.

    Global Tables needs streams enabled on the table to replicate between regions. You can check the requirements and how it works.

    http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables_HowItWorks.html

    If you have trigger, you can have only in one region. Whichever region is having the lambda associated to the trigger will get notified with the updates.

    The benefit from the global table you get is, if any regions updates the data, the lambda in the region you have configured will get triggered. Only one trigger will be sent to the lambda.

    Enabling streams is one of the requirements for DynamoDB Global Tables.

    If you create trigger in multiple regions, you need to implement your Lambda with idempotency i.e., if the same data is delivered any number of times, it will perform the operation only once.

    Hope it helps.