'AWS SQS sent 4 messages but lambda invoked twice

My SQS FIFO triggers lambda function. SQS sent 4 messages but lambda invoked twice. Concurrency is "Unreserved account concurrency & 1000". What can go wrong?



Solution 1:[1]

The AWS Lambda function can be invoked with more than one Record in the event.

For example, in Python you would process the event like this:

def lambda_handler(event, context):
    for record in event['Records']:
      message = record['Sns']['Message']
      print("From SNS: " + message)

The maximum number of messages passed to a Lambda function can be controlled with the Batch Size parameter in the trigger:

AWS Lambda trigger from SQS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1