Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda not invoked when subscribed SNS message is large

I've got a AWS lambda function that takes a large array of email addresses and submits them to SES for sending. The function is invoked via a SNS subscription. It works nicely when the message's email array size is small, however when the message's email array size is large the lambda function is NOT invoked. No logging occurs....

I've confirmed that the payload is below the SNS message size required, and I've subscribed to the SNS topic via my email...this works. I get emailed the expected message payload.

Any idea why this fails silently? Suggestions on how to work around this?

like image 371
tillerstarr Avatar asked Dec 25 '22 09:12

tillerstarr


2 Answers

For posterity:

Configure the 'Delivery Status' for the SNS topic. It will then log success/failures to CloudWatch.

Expect to see:

167542 byte payload is too large for the Event invocation type (limit 131072 bytes)

So...even though SNS can send a larger payload, that doesn't mean lambda's can be invoked with this size payload. Yuck!

like image 176
tillerstarr Avatar answered Jan 05 '23 19:01

tillerstarr


A couple workarounds for this:

1) Post the data to an S3 bucket. Have the Lambda function listen for Object CREATE on that bucket.

2) Post the data to S3, and publish an SNS event with just the bucket and key where the data can be found in S3. Have Lambda subscribe to the SNS topic.

In either case you're going to end up GET-ing the data from an S3 bucket inside your Lambda function. Now you have no size limits. :-)

like image 43
Todd Price Avatar answered Jan 05 '23 19:01

Todd Price