def handler()

in functions/source/asset-model-converter/handler.py [0:0]


def handler(event, context):
    logger.debug('event is {}'.format(event))

    assets_to_associate = []
    integration_points = integration_points_cache.get_all()

    try:
        for record in event['Records']:
            lifecycle_event = json.loads(record["body"])
            logger.info(f"lifecycle event: {lifecycle_event}")
            asset = process_event(lifecycle_event, integration_points)
            if asset:
                assets_to_associate.append(lifecycle_event)

        sqs.send_messages(assets_to_associate)

    except Exception as e:
        # Send some context about this error to Lambda Logs
        logger.error(e)
        # throw exception, do not handle. Lambda will make message visible again.
        raise e