Skip to content

Instantly share code, notes, and snippets.

@digitalbase
Created April 23, 2020 19:34
Show Gist options
  • Select an option

  • Save digitalbase/4988a0ff9dd57a64778718b666acece7 to your computer and use it in GitHub Desktop.

Select an option

Save digitalbase/4988a0ff9dd57a64778718b666acece7 to your computer and use it in GitHub Desktop.
// /src/utils/dynamo_stream.util.js
const AWS = require('aws-sdk');
const unmarshallNewImageEvent = (eventData) => {
if (!eventData.dynamodb) {
throw new Error('Not a dynamo event');
}
// if you want the raw event we need to unmarshall it
// more @ https://stackoverflow.com/questions/44535445/unmarshall-dynamodb-json
return AWS.DynamoDB.Converter.unmarshall(eventData.dynamodb.NewImage);
};
module.exports = {
unmarshallNewImageEvent
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment