I am trying to find a very nice python idiom to use aws boto3 paginators in the most "pythonic" way. Below is the best I have been able to come up with and I'm still not happy with it. Any ideas on how to make pagination simpler, possibly not using while True:?
import boto3
client = boto3.client('acm', region_name='ap-southeast-2')
paginator = client.get_paginator('list_certificates')
response_iterator = paginator.paginate()
while True:
for certificates in response_iterator:
for certificate in certificates['CertificateSummaryList']:
print(certificate)
if response_iterator.resume_token:
response_iterator = paginator.paginate(
PaginationConfig={
'StartingToken': response_iterator.resume_token
})
else:
break