def lambda_handler()

in code/document_classifier/document_classifier.py [0:0]


def lambda_handler(event, context):

    print("event: {}".format(event))
    if "Records" in event and event["Records"]:
        for record in event["Records"]:
            try:
                if "eventName" in record and record["eventName"] in ["INSERT", "MODIFY"]:
                    if "dynamodb" in record and record["dynamodb"] and "NewImage" in record["dynamodb"]:
                        print("Processing record: {}".format(record))
                        invokedItem = DynamoDBHelper.deserializeItem(record["dynamodb"]["NewImage"])
                        print(invokedItem)
                        processRequest(invokedItem)
                else:
                    print("Record not an INSERT or MODIFY event in DynamoDB")
            except Exception as e:
                print("Failed to process record. Exception: {}".format(e))