[AWS DA] API Gateway: Mapping Templates

What does it means?

For example, if we have setup a API Gateway, REST API, GET method point to a Lambda function with no proxy intergration which return:

{
  "statusCode": 200,
  "body": ""Hello from Lambda! mapping""
}

[Notice]: If we set with Proxy integration, we will only get the body from the response "Hello from Lambda! mapping"; Mapping template can NOT be used with proxy

If no proxy, then we get whatever Lambda function return to us.

Now we want to mask the response field to a different one:

In this case, we can use Mapping Templates.

To create a Mapping Template for a Method:

Here we renamed `statusCode` & `body`, and added new field `newField`.

原文地址:https://www.cnblogs.com/Answer1215/p/14836881.html