def process_lifecycle_event()

in functions/source/account_create.py [0:0]


def process_lifecycle_event(event):
    '''Handle Control Tower Life Cycle Event'''

    update_result = None

    LOGGER.info('LC Event: %s', event)
    service_event = event['detail']['serviceEventDetails']
    new_account = service_event['createManagedAccountStatus']
    cmd_status = new_account['state']
    account_id = new_account['account']['accountId']
    account_name = new_account['account']['accountName']
    message = new_account['message']

    try:
        update_result = update_account_status(account_name, account_id,
                                              cmd_status, message)
    except Exception as exe:
        LOGGER.error('Unable to update the record %s: %s',
                     account_name, str(exe))

    LOGGER.info('Update Status for %s : %s', account_name, update_result)