简体   繁体   中英

How to implement a Lambda trigger to fire once on a global dynamoDb table

I have a dynamoDb table that is setup as global (2019 version) between two regions.

I have a lambda function assigned as a trigger on the table. When a record is inserted into, say, the east version of the table then the east version of the lambda is triggered. The record is then replicated to the west version of the table and the west version of the lambda is triggered.

I want one lambda triggered. But I also want both triggers to be enabled in case one region goes down.

How can I achieve this? I would rather not make my trigger logic idempotent.

I don't know if this could be implemented without idempotency unless you want to make it extremely brittle and complicated. It is difficult if not impossible to obtain exactly once end-to-end delivery within a distributed system without using some kind of an idempotency filter.

Without knowing more about what you are doing, what about instead of writing into DynamoDB directly, you write to a local Step Function first. The data is processed in the step function and then it is written to DynamoDB. That way when it hits DynamoDB, it is already "processed" and the replication happens with no problems. I am not sure this would work as I do not know your full situation, but it might.

I think you can use a FIFO SQS for this. Lambda which responds to your dynamoDB stream can write to a FIFO SQS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM