By using AWS re:Post, you agree to the Terms of Use

Lambda with api gateway lambda_proxy integration error response


Hi!. I succesfully achieve to make lambda returning status code 400 and a message to the client. But in cloudwatch logs that execution even if i return status code 400 its returned like a success execution. I want to be able to "mark" that execution as an error and return the client a corresponding message with status code 400.
This is how i am returning the error

response = {
'statusCode': 400,
headers: {

            "Access-Control-Allow-Origin": "*",  
        'body': 'Error al obtener productos'  

return response;  

Thanks in advance.

asked 2 years ago60 views
4 Answers

Are they not showing up as "4XXError" apigateway cloudwatch metrics?

answered 2 years ago

Hi Ellison! Sry for the late response. No they arent the metrics all showing all as successfully execution.


answered 2 years ago

perhaps I should clarify, the metrics for the lambda should always show as successful, unless it crashes with an uncaught exception or something like that. The apigateway metrics are where you'd want to be looking for the different response codes.

answered 2 years ago

Thank you very much Ellison, i was looking the metrics for the lambda function and not in the api gateway. In the api metrics i can see the 400 errors.


answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions