We need to list all the stacks that are in CREATE_COMPLETE state. In our AWS account we have >400 such stacks. We have the following code written for this:
stack_session = session.client('cloudformation')
list_stacks = stack_session.list_stacks(StackStatusFilter=['CREATE_COMPLETE'])
However this lists only the first 100 stacks. We want to know how we can get all the stacks? We are using the python boto3 library.
I got this working using pagination. The code I wrote is below:
stack_session = session.client('cloudformation')
paginator = stack_session.get_paginator('list_stacks')
response_iterator = paginator.paginate(StackStatusFilter=['CREATE_COMPLETE'])
for page in response_iterator:
stack = page['StackSummaries']
for output in stack:
print output['StackName']
That printed all the 451 stacks that we needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With