I have an AWS lambda (written in Ruby) that is functioning as a web server. I access the lambda through an application load balancer. The following code works well for html, javascript, and css files.
{
statusCode: 200,
headers: {
'Content-Type' => "text/html"
},
body: File.open("index.html").read
}
I have added code that attempts to return binary data from the Lambda.
{
statusCode: 200,
headers: {
'Content-Type' => 'image/x-icon'
},
isBase64Encoded: true,
body: Base64.encode64(IO.binread("favicon.ico"))
}
If I invoke the lambda through the load balancer, I receive a "502 Bad Gateway" response from the load balancer. The load balancer logs show the following.
"error_reason"="LambdaInvalidResponse"
If I invoke the lambda from a command line with aws lambda invoke
, I see my 200 response and the expected response data.