def lambda_handler()

in code/lab-1/extraordinary_rides_service/app.py [0:0]


def lambda_handler(event, context):
    
    for e in event["Records"]:
    
        message = e["Sns"]["Message"]
        message_id = e["Sns"]["MessageId"]

        # will fail randomly to show the AWS Lambda retry feature
        if random.choice([True, False]):
            print("--------------------------------------")
            logger.info("{'msg-id': '%s', 'status': 'FAILED'}", message_id)
            print("--------------------------------------")
            raise SystemError("Unable to process fare")
        else:
            print("+++++++++++++++++++++++++++++++++++++++++")
            logger.info("{'msg-id': '%s', 'status': 'PROCESSED'}", message_id)
            print("+++++++++++++++++++++++++++++++++++++++++")