Last active
May 10, 2017 07:15
-
-
Save prestomation/63497eb0934960c755d7a7e927b26ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require("aws-sdk"); | |
var docClient = new AWS.DynamoDB.DocumentClient() | |
//Create a Translator object, which comes from the DocumentClient | |
var dynamodbTranslator = docClient.getTranslator(); | |
//It needs a SDK 'shape'. The individual Items in the Stream record | |
//are themselves the same Item shape as we see in a getItem response | |
var ItemShape = docClient.service.api.operations.getItem.output.members.Item; | |
module.exports.handler = function(event, context, callback) { | |
event.Records.forEach(function(record) { | |
//Let's just replace, in-place each Item with a 'translated' version | |
record.dynamodb.OldImage = dynamodbTranslator.translateOutput(record.dynamodb.OldImage, ItemShape); | |
record.dynamodb.NewImage = dynamodbTranslator.translateOutput(record.dynamodb.NewImage, ItemShape); | |
//Do Stuff With Your New Sane Record | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment