Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking Lambda when record inserted to dynamoDB

Need to invoke lambda when record inserted to dynamoDB table, But here i need to invoke lambda after 60 seconds of record insertion, is there any way that invoke lambda after n seconds?

like image 270
Narendar Reddy M Avatar asked Sep 10 '25 09:09

Narendar Reddy M


1 Answers

To solve this in a "scalable" manner I would use the following AWS products:

  1. DynamoDB Streams
  2. EventBridge
  3. Step Function

The process would look like this:

  1. As soon as your first Lambda inserts a new entry in your table, DynamoDB streams will be "triggered".
  2. You configure a Lambda to "listen" to the stream events.
  3. This Lambda should then put an event onto EventBridge. You do this instead of directly doing something here, because according to documentation, you should only have a maximum of two Lambdas "listening" on stream events. Therefore, I would recommend sending those "events" to EventBridge, so that you can add more/other processing steps to your DynamoDB streams. But this is optional.
  4. You create a rule in EventBridge that would trigger a Step Function with the appropriate payload (for example the DynamoDB keys you want to work on).
  5. The Step Function (as Artem described) could then contain a step that waits for n seconds, before another Lambda is triggered to run your code.
like image 105
Jens Avatar answered Sep 13 '25 05:09

Jens