4

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?

3 Answers 3

2

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.
Sign up to request clarification or add additional context in comments.

Comments

1

You can achieve such behavior with AWS StepFunctions. There is a special "wait" state, which is used to delay before next step.

So the idea is that state machine is launched in response to a new DynamoDB record, then it transits to the "wait" step (60 sec) and then transits to a "task" step with your lambda function.

Comments

0

You could trigger a lambda that writes your DynamoDB events to a SQS Queue, which is getting polled by your initial lambda. Then you could customize the polling intervall and therefore the duration your lambda gets invoked after something was inserted into the table.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.