Is there a way aws lambda can wait (block and not run/sleep) on an event for a certain amount of time (say 10 hour) and if event isnt received in the window, lambda timeout and raises error. If not with lambda can it be acheived with other aws tech like eventbridge, step function etc?
CodePudding user response:
Lambda run time is only 15 mins max - you can however have another set of lambda's set up that use the SDK to do what you wish - You can use the SDK to either disable / redirect the endpoint the lambda you wish to sleep is at, you can disable invocations, you can (and this would be my suggestion) have a variable stored in the SSM Parameter store that you update that bypasses all the structure in the lambda itself.
You can then use the SDK to set up a TTL/Timed Event to re-enable the parameter store variable after a given time (through the use of another lambda)
CodePudding user response:
When the delay is less than 30 seconds or so, then you can just wait inside the lambda. For longer delays, you should send an SQS message with a delay, and configure your lambda to process it.
The maximum delay you can get from SQS is only 15 minutes, but you can just pick it up and resend with a new delay if you need longer. It'll be very inexpensive.