DEV Community


Discussion on: AWS Lambda SQS events with Serverless Framework

jsiesquen profile image
Juan Siesquen

Make a test on API Gateway POST verb and your log show me is:
Execution failed due to configuration error: Malformed Lambda proxy response
Method completed with status: 502

But have well formed my response in my sender....

var response = {
"statusCode": responseCode,
"headers": {
"Content-Type": "application/json"
"body": JSON.stringify(responseBody),
"isBase64Encoded": false

Read this...

But nothing! wuu

piczmar_0 profile image
Marcin Piczkowski Author

Can you put your whole handler code somewhere, e.g
on gist to check how the function looks like?

Thread Thread
jsiesquen profile image
Juan Siesquen

I just re-created the sender.js and it goes well. I think he wrote something wrong. The important thing is that I could check how the data exchange between lambda and SQS works. Thank you!

Only a tiny addition:
if (err) {
console.log('error:', "failed to send message" + err);
responseCode = 500;
responseBody = err;

I did not understand the concurrency part yet. If my Lambda has more than 2000 records to send to SQS, I will send them one by one to the queue. I think the lambda will take a long time, can I send batch queues? Each record is a message to the queue.

Maybe it illuminates us with an additional post about this?

Thank you so much Marcin!

Thread Thread
piczmar_0 profile image
Marcin Piczkowski Author

you are allowed to send at most 10 messages in single batch

I would delegate this task to multiple lambdas if you need to send batches concurrently to speedup.