def lambda_handler()

in lambda/sqs/app.py [0:0]


def lambda_handler(event, context):
    logger.info(event)

    batch_failures = []
    batch_ids = []

    for record in event['Records']:
        message_body = json.loads(record['body'])
        batch_ids.append(message_body['id'])

        # Unlike Kinesis and Dynamo lambdas, we continue here as we can report on all failed messages
        if 'error' in message_body['id']:
            batch_failures.append({"itemIdentifier": record["messageId"]})
            continue

    logger.debug(batch_ids)

    return {"batchItemFailures": batch_failures}