def _get_alternate_workflow()

in source/Orchestrator/get_approval_requirement.py [0:0]


def _get_alternate_workflow(accountid):
    """
    Get the alt workflow based on environmental variables for this lambda
    and whether the alt runbook is active. Note that alt workflow must run
    in the same region as the Step Function.
    """
    running_account = boto3.client('sts').get_caller_identity()['Account']

    # Is an alternate workflow defined?
    WORKFLOW_RUNBOOK = os.getenv('WORKFLOW_RUNBOOK', '')
    WORKFLOW_RUNBOOK_ACCOUNT = os.getenv('WORKFLOW_RUNBOOK_ACCOUNT', 'member')
    WORKFLOW_RUNBOOK_ROLE = os.getenv('WORKFLOW_RUNBOOK_ROLE', '')

    # Disabled by removing the Lambda environmental var or setting to ''
    if not WORKFLOW_RUNBOOK:
        return (None, None, None)

    if WORKFLOW_RUNBOOK_ACCOUNT.lower() == 'member':
        WORKFLOW_RUNBOOK_ACCOUNT = accountid
    elif WORKFLOW_RUNBOOK_ACCOUNT.lower() == 'admin':
        WORKFLOW_RUNBOOK_ACCOUNT = running_account
    else:
        # log an error - bad config
        LOGGER.error(f'WORKFLOW_RUNBOOK_ACCOUNT config error: "{WORKFLOW_RUNBOOK_ACCOUNT}" is not valid. Must be "member" or "admin"')
        return (None, None, None)

    # Make sure it exists and is active
    if _doc_is_active(WORKFLOW_RUNBOOK, WORKFLOW_RUNBOOK_ACCOUNT):  
        return(WORKFLOW_RUNBOOK, WORKFLOW_RUNBOOK_ACCOUNT, WORKFLOW_RUNBOOK_ROLE)
    else:
        return(None, None, None)