I am trying to properly setup Body Mapping and Header Mapping in the Integration Response for an API Gateway endpoint.
In our Lambda we have
if (res
Did you try to use Lambda Error Regex in Integration Response? For example:
.*"status":400.*
body mapping templetes:
#set ($errorMessageObj = $util.parseJson($input.path('$.errorMessage')))
{
"status" : "$errorMessageObj.status",
"errorType" : "$errorMessageObj.errorType",
"message" : "$errorMessageObj.errorMessage"
}
I created an error function in my Lamda:
function error(status, errorType, errorMessage, callback){
callback(JSON.stringify({
status: status,
errorType: errorType,
errorMessage: errorMessage
}));
}
usage:
error(404, "Not Found", "Resource is not found", callback);