Mapping Lambda output in API Gateway gives server error

前端 未结 1 856
孤独总比滥情好
孤独总比滥情好 2021-02-14 19:57

I have an AWS API Gateway setup, served by a Python Lambda function. For successful responses the Lambda returns a response of the form:

\"200:{\\\"somekey\\\":          


        
相关标签:
1条回答
  • 2021-02-14 20:22

    If you do a test run in API gateway, the test run log should show an error similar to:

    Sat Nov 21 07:41:25 UTC 2015 : Execution failed due to configuration error: No match for output mapping and no default output mapping configured

    The problem is there is no-longer a default mapping to catch a successful response. The intention of the error regex is to catch errors and map them to status codes. The error regex searches the errorMessage property of the failed json response. If you were to set the status code 400 to be the default (blank) - you would find your successful response always mapping to a status code of 400.

    You'll be best off to leave 200 as a default (blank) regex. Then set specific regex values to check for your different error messages. For example, you can have multiple specific error regex status codes and a generic catch-all to result in 500's.

    0 讨论(0)
提交回复
热议问题