Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS lambda event parameters: When does Records hold multiple items in it?

I have an infrastructure such as this: S3 -> SQS -> Lambda. When a file is dropped to S3, it puts the event into an SQS queue, which then is consumed by a lambda function.

Lambda is written in .net core. In lambda handlers parameter, I receive an SQSEvent and within its body, an S3Event that is serialized to Json.

The class structures are roughly as below. They are straight from the AWS .net SDK.

class SQSEvent
{
    public List<SQSMessage> Records;
    ...
}

class SQSMessage
{
    public string Body; // json serialized S3Event is put into here
    ...
}

class S3Event
{
    public List<S3EventNotification> Records;
    ...
}

The part I'm curious about is that, both SQSEvent and S3Event have a list of records. In my experiments, I always received a single item in those lists. Is it known under which circumstances any of these Records list will contain multiple items in it? I failed to find a document stating about this behaviour.

like image 480
Tolga Evcimen Avatar asked Oct 21 '25 13:10

Tolga Evcimen


1 Answers

If many records are generated in a very short amount of time, for example if many S3 files were uploaded simultaneously, then Amazon may send a list of records in a single event.

like image 145
Mark B Avatar answered Oct 23 '25 03:10

Mark B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!