-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General solution for paginating AWS endpoints #63
Labels
enhancement
New feature or request
Comments
I think this is it: def paginate(service, method, list_key, **kwargs):
paginator = service.get_paginator(method)
for response in paginator.paginate(**kwargs):
yield from response[list_key] |
Which simplifies @cli.command()
@common_output_options
@common_boto3_options
def list_users(nl, csv, tsv, **boto_options):
"List all users"
iam = make_client("iam", **boto_options)
output(
paginate(iam, "list_users", "Users"),
(
"UserName",
"UserId",
"Arn",
"Path",
"CreateDate",
"PasswordLastUsed",
"PermissionsBoundary",
"Tags",
),
nl,
csv,
tsv,
) |
simonw
added a commit
that referenced
this issue
Jan 19, 2022
Wrote this up as a TIL: https://til.simonwillison.net/aws/helper-for-boto-aws-pagination |
simonw
added a commit
that referenced
this issue
Jan 25, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need a general solution for pagination. Maybe something like this:
The
paginate()
function would wrap this pattern, seen elsewhere:Originally posted by @simonw in #62 (comment)
The text was updated successfully, but these errors were encountered: