def list_stack_instance_by_region()

in code/ct_flowlog_activator.py [0:0]


def list_stack_instance_by_region(target_session, stack_set_name, region):
    '''
    List all stack instances based on the StackSet name and region
    '''
    try:
        cfn_client = target_session.client('cloudformation', region_name=region)
        cfn_paginator = cfn_client.get_paginator('list_stack_instances')
        operation_parameters = {
            'StackSetName': stack_set_name
        }
        stackset_result = cfn_paginator.paginate(**operation_parameters)
        stackset_list = []

        for page in stackset_result:
            if 'Summaries' in page:
                stackset_list.extend(page['Summaries'])

        return stackset_list

    except Exception as e:
        LOGGER.error("List Stack Instance error: %s" % e, exc_info=True)
        return []