Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created May 23, 2023 08:54
Show Gist options
  • Save saswata-dutta/f0c21708df12a04df09642692ad5a15e to your computer and use it in GitHub Desktop.
Save saswata-dutta/f0c21708df12a04df09642692ad5a15e to your computer and use it in GitHub Desktop.
aws lambda batch item fails
console.log('Loading function');
exports.handler = async (event) => {
//console.log('Received event:', JSON.stringify(event, null, 2));
const fails = [];
for (const { messageId, body } of event.Records) {
console.log('SQS message %s: %j', messageId, body);
fails.push(messageId);
}
// throw new Error('intentional');
return {
batchItemFailures: fails.map(i => ({itemIdentifier: i}))
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment