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?
DelaySeconds
will delay the delivery of the message to the queue in the specified amount of time. It doesn't mean it will be invisible for that amount of time, so as soon as the message hits the queue, your Lambda function tries to pick it up. I am afraid what you're trying to achieve is impossible. I really don't see a great benefit of doing it. Maybe if you refactor your architecture a little bit you won't need these types of workarounds – Crisis