in functions/source/stackset/stackset.py [0:0]
def list_stack_instance_by_account(target_session, stack_set_name, account_id):
'''
List all stack instances based on the StackSet name and Account Id
'''
try:
cfn_client = target_session.client('cloudformation')
stackset_result = cfn_client.list_stack_instances(
StackSetName = stack_set_name,
StackInstanceAccount=account_id
)
if stackset_result and 'Summaries' in stackset_result:
stackset_list = stackset_result['Summaries']
while 'NextToken' in stackset_result:
stackset_result = cfn_client.list_stackset_instance(
NextToken = stackset_result['NextToken']
)
stackset_list.append(stackset_result['Summaries'])
return stackset_list
else:
return False
except Exception as e:
LOGGER.error("List Stack Instance error: %s" % e)
return False