def lambda_handler()

in code/ct_flowlog_activator.py [0:0]


def lambda_handler(event, context):
    LOGGER.info('Lambda Handler - Start')
    LOGGER.info('REQUEST RECEIVED: {}'.format(json.dumps(event, default=str)))

    # If called from cloudformation as custom resource...
    if 'RequestType' in event:
        LOGGER.info("Using Cloudformation custom resource handler")
        cfn_handler(event, context)

    # Primary handler - takes cloudwatch timer and recursively call lambda for each accounts in the Org
    elif 'detail-type' in event and event['detail-type'] == 'Scheduled Event':
        LOGGER.info("Using CloudWatch Timer Handler")
        primary_handler(context)

    # Child handler - takes event from master Lambda, scan each active regions for VPCs
    elif 'child-thread' in event:
        LOGGER.info("Starting thread : {}".format(event['account']))
        child_handler(event, context)

    # Custom handler takes Event Bus from hub account for tag update at subnet and vpc level
    elif 'detail-type' in event and event['detail-type'] == 'Tag Change on Resource':
        LOGGER.info("Using Event Bus Handler")
        eventbridge_handler(event, context)

    else:
        LOGGER.error("Invalid event received : {}".format(event))
    LOGGER.info('Lambda Handler - End')