11
votes

I am currently exploring storing the attachments of an email separately from the .eml file itself. I have an SES rule set that delivers an inbound email to a bucket. When the bucket retrieves the email, an S3 Put Lambda function parses the raw email (MIME format), base64 decodes the attachment buffers, and does a putObject for each attachment and the original .eml file to a new bucket.

My problem is that this Lambda function does not trigger for emails with attachments exceeding ~3-4 MB. The email is received and stored in the initial bucket, but the function does not trigger when it is received. Also, the event does not appear in CloudWatch. However, the function works perfectly fine when manually testing it with a hardcoded S3 Put payload, and also when manually uploading a .eml file to the assigned bucket.

Do you have any idea why there is this limitation? Perhaps this is a permission issue with the bucket or maybe an issue with the assigned Lambda role? When manually testing I’ve found this is by no means a timeout or exceeding max memory used issue.

3
Possible duplicate of Is it possible for S3 notifications to SQS to fail?. Not precisely the same on the surface -- but the same probable underlying cause, so for the moment, I'm going to say it isn't an exact duplicate. I'd prefer to see some consensus on that rather than sling my golden dupe hammer around casually. – Michael - sqlbot
@Michael-sqlbot I wouldn't flag this question as a duplicate because I would never have expected anyone to find that other question while searching for this issue. The title of that other question is too vague for someone to find it when experiencing this issue. – Mark B
Thanks @MarkB. I suspect you're right. – Michael - sqlbot

3 Answers

33
votes

The larger files are almost certainly being uploaded via S3 Multipart Upload instead of a regular Put operation. You need to configure your Lambda subscription to also be notified of Multipart uploads. It sounds like the function is only subscribed to s3:ObjectCreated:Put events currently, and you need to add s3:ObjectCreated:CompleteMultipartUpload to the configuration.

3
votes

I faced the same issue.If the Etag of the file you uploaded to S3 ends with a hyphen followed by a number then it denotes the file was uploaded using Multipart. Subscribing to CompleteMultipartUpload Event resolved the issue.

0
votes

I was getting same issue. Despite having s3:ObjectCreated:CompleteMultipartUpload as event notification, the trigger failed.

I later realized that the issue was with the lambda's timeout period. This could also be a potential issue.