Skip to content

Instantly share code, notes, and snippets.

@ronan-cunningham
Last active September 25, 2024 07:12
Show Gist options
  • Save ronan-cunningham/eefa64a2b84ae94abd77d55cb9b579e5 to your computer and use it in GitHub Desktop.
Save ronan-cunningham/eefa64a2b84ae94abd77d55cb9b579e5 to your computer and use it in GitHub Desktop.
Using "nextToken" with a boto client
from botocore.config import Config
region='eu-west-1'
config = Config(
region_name = region,
retries = {
'max_attempts': 10,
'mode': 'standard'
}
)
def get_all_log_groups(client):
args={}
response = client.describe_log_groups(**args)
results = response["logGroups"]
while "nextToken" in response:
args['nextToken']=response["nextToken"]
response = client.describe_log_groups(**args)
results.extend(response["logGroups"])
return results
client=boto3.client('logs',config=config)
get_all_log_groups(client)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment