-
Notifications
You must be signed in to change notification settings - Fork 0
Mapping Template & Proxy Integration
Examples of mapping templates:
- Change the key name based on value
#set($inputRoot = $input.path('$')) { "count": $inputRoot.count, "items": [ #foreach($elem in $inputRoot.items) { "author": { #if ("$elem.author.last_name" == 'Doe') {"lastname": "$elem.author.last_name"} #else {"last": "$elem.author.last_name"} #end , "email": "$elem.author.email", "first_name": "$elem.author.first_name" } }#if($foreach.hasNext),#end
#end ], "version": $inputRoot.version }
- Assign key name from JSON payload to PartitionKey.
#set ($bodyObj = $util.parseJson($input.body))
{
"StreamName": "cox-poc-test-stream",
"Data": "$util.base64Encode(
Example of Proxy Integration:
For proxy integration, lambda function must return output in specific format.
exports.handler = (event, context, callback) => { var responseBody = { "requestId": context.awsRequestId, "logGroupName": context.logGroupName };
var response = {
"statusCode": 200,
"headers": {
"my_header": "my_value"
},
"body": JSON.stringify(responseBody),
"isBase64Encoded": false
};
callback(null, response);
};