def get_portfolio_id()

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


def get_portfolio_id(prod_id):
    ''' Find the Portfolio Id of AWS Control Tower Account Factory '''

    af_name = 'AWS Control Tower'
    key = 'ProviderName'
    output = None
    port_list = []

    try:
        port_list = SC.list_portfolios_for_product(
            ProductId=prod_id)['PortfolioDetails']
    except Exception as exe:
        LOGGER.error('Unable to find Product Id: %s', str(exe))

    for item in port_list:
        if key in item:
            if item[key] == af_name:
                output = item['Id']
                break
        else:
            LOGGER.warning('Unexepected output recieved. Skipping: %s', item)

    if not output:
        LOGGER.error('Unable to find Product Id: %s', str(port_list))

    return output