I have a lambda configured to be triggered when messages are published to SQS queue. Here is the SAM template for deployment.
MyQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 180
DelaySeconds: 90
MyLambda:
Type: AWS::Serverless::Function
Properties:
CodeUri: ../pathToCode
Handler: index.handler
Events:
MySQSEvent:
Type: SQS
Properties:
Queue: !GetAtt MyQueue.Arn
I am using DelaySeconds
property of AWS::SQS::QUEUE
which apparently doesn't work. My lambda get executed as soon as the message is published to queue. How can I put delay in it?
The best solution is to use AWS Step Functions.
The lambda triggered by the SQS should execute a state machine, where the first step is the required amount of sleep, and the second one is the lambda invocation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With