Bhargav Pratapagiri
Bhargav Pratapagiri

Reputation: 31

S3 triggering Lambda even if the file size is 0

Hi have a use case where a file gets uploaded in S3 and it then triggers a Lambda function. Sometimes, a corrupt file or a file with 0 size gets uploaded and since its an event, it triggers my Lambda function. The Lambda should not be invoked if the filesize of S3 object is 0.

Can we achieve this?

Upvotes: 2

Views: 801

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269826

No, you cannot configure Lambda to 'not trigger' no a zero-length object.

Instead, you can add code to the start of the Lambda function that looks at the object size that is passed in the event record, and then exits if the size is zero.

The path is: Records[].s3.object.size

Upvotes: 3

Related Questions