InvalidLambdaresponse : While calling a Java Handler sitting behind an ALB

0

I'm trying to invoke a Lambda (Java 8) using a DNS endpoint --> ALB --> Lambda as the target group. Lambda does what its supposed to do (Upload a file in S3) upon its invocation but on the postman or curl command i see a 502 error . When i check the ALB logs it says InvalidLambdaResponse

My lambda is returning a Map (String , Object). When i print the JSON it looks good as well. What am i missing here ?

{ "headers": { "Cache-Control": "no-store", "Content-Type": "application/json" }, "isBase64Encoded": "False", "statusCode ": "200", "statusDescription ": "200 OK", "body": "Lambda S3 Upload" }

질문됨 2년 전563회 조회
1개 답변
0
수락된 답변

It looks like there are a few small errors in the format of the object you're returning. There are some additional spaces in some of the keys (might just be an effect of copy and paste), isBase64Encoded should be boolean, and statusCode should be an integer. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#respond-to-load-balancer

This slightly modified version seems to work:

{
  "headers": {
    "Cache-Control": "no-store",
    "Content-Type": "application/json"
  },
  "isBase64Encoded": false,
  "statusCode": 200,
  "statusDescription": "200 OK",
  "body": "Lambda S3 Upload"
}
Ed
답변함 2년 전
  • Thanks Ed ! Yes the spaces on statusCode and statusDescription were the culprit .

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠