I am trying to figure out how to map a Response from Lambda in the API Gateway to different status codes and at the same time receive a JSON object from my Lambda-function.
I have the following in Lambda:
context.done('Not Found:',jsonObject);
And in my API Gateway, in integration response I have a Lambda error regex on 403 saying Not Found:.*. This works, the method is returning a returning a 403.
The problem is I can't seem to return the jsonObject. I have tried to create a application/json mapping template that looks like this (also under integration response):
{"error" : $input.json('$')}
But that only results in my response looking like this:
{"error" : {"errorMessage":"Not Found:"}}
Am I misunderstanding the mapping template?