1 Answer
- Newest
- Most votes
- Most comments
0
Hello,
Please refer to the following post https://repost.aws/questions/QUnI9Nj79iTWO76uK0E0DrSQ/sample-error-handling-and-custom-http-status-codes-in-spring-cloud-function-lambda-gateway
The ResponseParameter to map is $response.body.statusCode
:
LambdaIntegration: Type: AWS::ApiGatewayV2::Integration Properties: ApiId: !Ref MyAPI IntegrationMethod: POST IntegrationType: AWS_PROXY IntegrationUri: !GetAtt MyFunction.Arn PayloadFormatVersion: '2.0' RequestParameters: "append:header.header1": "$context.requestId" ResponseParameters: - Source: "$response.body.statusCode" # <------ notice the $ Destination: "overwrite:statusCode"
Edit for some clarifications:
- you don't need to map manually the statusCode, the lambda can directly return the statusCode. exemple from the documentation
// bare minimum lambda function to return 404 response exports.handler = async (event, context) => { console.log('returning code 404'); return { "isBase64Encoded": false, "statusCode": 404, "body": "Hello from Lambda!", "headers": { "content-type": "application/json" } }; };
- you might want to check your lambda java code and try sending the same json from documentation which is known to be working.
- run a test directly from the lambda test page and see what is the response.
answered a year ago
Relevant content
- asked a year ago
- asked a month ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
I updated it to "$response.body.statusCode". It didn't work either. Not sure what other configurations that I can try
@rePost-User-3677295 I've updated my answer. the issue should come from the lambda itself