AWS API Gateway & Kinesis Firehose Integration: Adding Additonal data
<p>I am currently using the following mapping template to pass data sent to an AWS API Gateway endpoint to AWS Kinesis Firehose stream:</p>

<pre class="lang-js prettyprint-override"><code>{
    "DeliveryStreamName": "[STREAMNAME]",
    "Record": {
        "Data": "$util.base64Encode($input.body)"
    }
}
</code></pre>

<p>What I would like to do is: adding information to the <code>$input.body</code> that is being encoded like the <code>$context.identity.sourceIp</code> of the client making the request.</p>

<p>How can I go about this when the output being passed to Kinesis Firehose needs to be Base64-encoded? Ideally I would like my data that is being posted to Kinesis Firehose look like this:</p>

<pre class="lang-js prettyprint-override"><code>{
  "x": 1,
  "y": 2,
  "z": 3,
  ...,                   // all the properties from the JSON-request by the client
  "clientIp": "x.x.x.x"  // property added by API-Gateway into client's object
}
</code></pre>