Issue
I trying to call a lambda function in dynamic delay time from another lambda function. For example, when you get a message with "success" in A lambda function, it will call B lambda function in one minute.
I don't want to use settimeout as I can't afford paying for sleep time in lambda.
I have found couple of solutions that are using Event Bridge, Step function and cloudwatch. However, all of these are using fixed delay time instead of dynamic delay time. What I mean by dynamic delay time is to call B lambda function with a time I set on the code which can be manipulated. As the solutions above set the time on their definition or configuration, I am not able to access and modify it on the code.
Please save me
Solution
Since the delay time is dynamic, we can use Message Timers options in SQS.
What you have to do is, place a SQS instance in-between Lambda A and Lambda B. Then the Lambda A should place a message in the queue along with the DelaySeconds specified (Then that message will not visible in the queue until that specified DelaySeconds elapsed).
Then add that SQS as a trigger to Lambda B. So what happen is, the message placed by Lambda A will visible in the queue after the DelaySeconds passed. Then it will invoke the Lambda B.
Please note that, the maximum value which we can specify for DelaySeconds is 900 (15 mins). So this will not work if you need more delay than that.
Answered By - Sampath Dilhan Answer Checked By - Cary Denson (WPSolving Admin)