src/account_inventory.py
def list_all_aws_accounts():
    """
    Gets the current list of all AWS Accounts from AWS Organizations.

    :return The current dict of all AWS Accounts.
    """
    account_list = []
    try:
        # max limit of 20 users per listing
        # use paginator to iterate through each page
        paginator = org_client.get_paginator('list_accounts')
        page_iterator = paginator.paginate()
        for page in page_iterator:
            for acct in page['Accounts']:
                account_list.append(acct)
    except org_client.exceptions.ClientError as error:
        log.error(f'Error: {error}')

    return account_list

    Gets the current list of all AWS Accounts from AWS Organizations.

    :return The current dict of all AWS Accounts.
    
Gets the current list of all AWS Accounts from AWS Organizations.
:return The current dict of all AWS Accounts.
Gets the current list of all AWS Accounts from AWS Organizations . : return The current dict of all AWS Accounts .
def list_all_aws_accounts():
    account_list = []
    try:
        paginator = org_client.get_paginator('list_accounts')
        page_iterator = paginator.paginate()
        for page in page_iterator:
            for acct in page['Accounts']:
                account_list.append(acct)
    except org_client.exceptions.ClientError as error:
        log.error(f'Error: {error}')
    return account_list
def list_all_aws_accounts ( ) : account_list = [ ] try : paginator = org_client . get_paginator ( 'list_accounts' ) page_iterator = paginator . paginate ( ) for page in page_iterator : for acct in page [ 'Accounts' ] : account_list . append ( acct ) except org_client . exceptions . ClientError as error : log . error ( f'Error: {error}' ) return account_list
Gets the current list of all AWS Accounts from AWS Organizations.
Gets the current list of all AWS Accounts from AWS Organizations .
"""
    Gets the current list of all AWS Accounts from AWS Organizations.

    :return The current dict of all AWS Accounts.
    """ # max limit of 20 users per listing # use paginator to iterate through each page