Search code examples
pythonamazon-web-servicesaws-lambdaboto3amazon-sqs

How to set maximumBatchingWindowInSeconds for AWS SQS in serverless.yml?


I have created a serverless.yml file using serverless library. I have created a lambda service and SQS Service. However I am unable set the maximum batching window property in serverless. Currently it is set to 0 and lambda is invoked with single payload.

I have tried using batchWindow property but it doesn't work.

  events:
  - sqs: 
      arn: 
        Fn::GetAtt: [ sqsQueue, Arn ]
      batchSize: 4
      batchWindow: 40

I have also tried using maximumBatchingWindowInSeconds property but still the value is 0.

  events:
  - sqs: 
      arn: 
        Fn::GetAtt: [ sqsQueue, Arn ]
      batchSize: 4
      maximumBatchingWindowInSeconds: 40

Is there a way we can do it by overriding aws cloudformation resources in serverless? https://www.serverless.com/framework/docs/providers/aws/guide/resources/#override-aws-cloudformation-resource


Solution

  • correct syntax can be found below:

    events:
          - sqs:
              arn: arn:aws:sqs:region:XXXXXX:myQueue
              batchSize: 10
              maximumBatchingWindow: 60
    

    Please make sure that you're using the latest version of the Framework.

    Docs: https://www.serverless.com/framework/docs/providers/aws/events/sqs