- 新しい順
- 投票が多い順
- コメントが多い順
The problem has been fixed -> There was a JSON format issue in the response returned by the lambda. The function returned 200 both locally and from AWS with the Console and AWS CLI but failed with 500 when called via the API Gateway v2 with curl. The "body" part of the response had to be escaped when it is a JSON (simple string had no issue).
There is unfortunatelly no example of "body" in https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
Expected format as seen in the Console Lambda/Test execution log '{ "isBase64Encoded": false, "statusCode": 200, "body": "{ \"allo\": \"hehe\" }" }'
Code used in the bash handler:
ESCAPED=$(echo "$EVENT_DATA" | sed 's/"/\\"/g')
RESPONSE="{ \"isBase64Encoded\": false, \"statusCode\": 200, \"body\": \"$ESCAPED\" }"
echo $RESPONSE
Code used in the nodejs handler:
return {
"isBase64Encoded": false,
"statusCode": 200,
"body": JSON.stringify(event)
};
GitHub repository https://github.com/Ducharme/awsCustomLambdas was updated to include the fixes. Hope this helps
If you haven't gone through following articles, please take a look at these. These two talk about the same problem in very detail:
Hope you find this useful.
Comment here if you have additional questions.
Abhishek
Thanks for the links, they gave me more perspective. The call is successful with exactly same lambda via API Gateway v2 when the "aws apigatewayv2 create-integration" command argument "--integration-type" is "HTTP_PROXY" with Function URL instead of "AWS_PROXY" with the lambda ARN. Would it be possible to provide a more specific solution for the AWS_PROXY integration problem? Thanks
Things that did not work or do not apply in the setup:
- HTTP APIs currently support access logging only
- There is no error in the Lambda function code
- Permissions are set properly for the lambda (it is called and returns OK)
- Incorrect or missing HTTP status code mapping does not seem to apply to v2
- Throttling issues -> There is only one call every 1-2 minute or so approx
- Undefined HTTP method of POST -> Does not seem to be relevant for v2
- Lambda permissions is set properly since it is called and logs are as expected
- Lambda function JSON format issue -> Multiple payloads were tried
- Backend payload size exceeding 10 MB -> Less than 50 byes are returned
- Private endpoint integration -> Not used
I also tried docker image ubuntu:18.04 as base instead of ubuntu:22.04.
Other attempts were made to change/override ENTRYPOINT and CMD in the Dockerfile and in the Lambda (different permutations of /var/task/aws-lambda-rie, /var/task/bootstrap, function.handler). It normally gives "Error: Runtime exited with error: exit status 2" and sometimes "[PANIC] (rapid) Runtime API Server failed to listen error=listen tcp 127.0.0.1:9001: bind: address already in use" when testing the lambda in the console.
関連するコンテンツ
- AWS公式更新しました 1年前
Did you take a look at here
To create a HTTP integration request
Command:
To create an AWS integration request with a Lambda Function endpoint
Command:
Link provided is to put-integration with AWS CLI v1 is for API Gateway v1 (apigateway). My code in https://github.com/Ducharme/awsCustomLambdas/blob/master/create_api.sh is using AWS CLI v2 for API Gateway v2 (apigatewayv2) as mentioned in the title and first comment. Have you been able to reproduce the issue?
Here is the command to handle the integration for easy reference aws apigatewayv2 create-integration --api-id $API_ID --integration-type AWS_PROXY --integration-uri $LAMBDA_ARN --payload-format-version "1.0"
Note: adding "--integration-method $ROUTE_VERB" makes no difference