Skip to content

Instantly share code, notes, and snippets.

@sonjisov
Created March 22, 2020 04:27
Show Gist options
  • Save sonjisov/af154d38d671095ec3391313450fc8b1 to your computer and use it in GitHub Desktop.
Save sonjisov/af154d38d671095ec3391313450fc8b1 to your computer and use it in GitHub Desktop.
const publishToKinesis = async (payload) => {
// Publishing logic here which is irrelevant now
};
// NOTE : Although I believe that this code is mostly correct, I confess that I never ran it
// so it may contain some minor syntax errors or something like that....
export const handler = ({ Records: dynamoDbRecords }) => {
const promises = dynamoDbRecords.map(({ dynamodb: { OldImage: oldImage } }) => {
if (oldImage && oldImage.recordType === 'STATUS_TASK') { // We interested only in deleted records of type STATUS_TASK
return oldImage;
}
return null;
}).filter(r => r);
await Promise.resolveAll(promises);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment