Last active
September 25, 2024 07:12
-
-
Save ronan-cunningham/eefa64a2b84ae94abd77d55cb9b579e5 to your computer and use it in GitHub Desktop.
Using "nextToken" with a boto client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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