EtienneG
EtienneG

Reputation: 320

RequestEntityTooLargeException for a lambda invoke

I have a lambda function calling another lambda function using the lambda invoke method:

lambda.invoke({
    FunctionName: 'MyOtherLambda',
    InvocationType: 'Event',
    Payload: myBigObject
}, callback);

I am using InvocationType: 'Event' to stop this first lambda without waiting for MyOtherLambda to finish. The thing is I get the following error:

RequestEntityTooLargeException: 179206 byte payload is too large for the Event invocation type (limit 131072 bytes)

Removing InvocationType: 'Event' indeed makes it work but the lambda keeps running for nothing. I tried to use the deprecated invokeAsync method but this leads to the same error.

How can I pass a large Payload without waiting for the second lambda to complete and why is the size of the Payload limited when using InvocationType: 'Event' ?

Upvotes: 3

Views: 12690

Answers (1)

Jarred Olson
Jarred Olson

Reputation: 3243

Per the documentation you are limited to 256 KB payload size using Event invocation type. RequestResponse invocation type (the default) allows for 6 MB.

  • One way you can get around this is to upload the file to S3 in your first lambda, then pass the bucket and key as the payload to the 2nd lambda.

  • You could also have the 2nd lambda's trigger be the upload to S3.

Upvotes: 6

Related Questions