dinogalactic

You should use boto3 paginators

I wanted to point out that you may want to refactor your boto code, depending on how much time you have, to use a paginator rather than handling the nextToken from the AWS API yourself. This will return an API response on each iteration over the paginator.

Here's an example run against my personal AWS account, which only has one page of CFN stacks unfortunately:

In [19]: import boto3                                                                                                                                                                         
In [20]: boto3.client('cloudformation')                                                                                                                                                       
Out[20]: <botocore.client.CloudFormation at 0x7f9abc2fbaf0>
In [21]: cfn_client = boto3.client('cloudformation')                                                                                                                                          
In [23]: cfn_client.can_paginate('describe_stacks') # Figure out if you can paginate your desired cfn_client command before using this technique                                                                                                                                            
Out[23]: True
In [24]: paginator = cfn_client.get_paginator('describe_stacks')                                                                                                                              
In [29]: for resp in paginator.paginate(): # You can also pass in any keyword args that cfn_client.describe_stacks() would take here, like paginator.paginate(StackName='blahblahblah') 
    ...:     print([stack['StackName'] for stack in resp['Stacks']]) 
    ...: 
['chickenpi-app-epp', 'gg-service-role', 'chickenpi-pl-epp', 'cfn-leaprog-trail', 'aws-cloud9-Python-Development-Environment-f5f7b7b71b124224a4472c8768327a97', 'aws-sam-cli-managed-default']

Here are the boto3 pagination docs.