Skip to content
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

Use Pagination in (List) AWS API Calls #3

Open
adrianosela opened this issue Jun 19, 2023 · 0 comments
Open

Use Pagination in (List) AWS API Calls #3

adrianosela opened this issue Jun 19, 2023 · 0 comments

Comments

@adrianosela
Copy link
Contributor

Currently, we only get one page of results.

The aws go sdk v2 introduced a nice way to handle paginated results. e.g. for ECS clusters:

    client := ecs.NewFromConfig(cfg)

    // initialize the ListClustersPaginator with the ListClustersInput
    paginator := ecs.NewListClustersPaginator(client, &ecs.ListClustersInput{})

    // Loop until there are no more pages left
    for paginator.HasMorePages() {
        output, err := paginator.NextPage(context.TODO())
        if err != nil {
            log.Fatalf("failed to get a page, %v", err)
        }

        // process the page's results
        fmt.Println("Page results:", output.ClusterArns)
    }

    if paginator.Err() != nil {
        log.Fatalf("error occurred during pagination, %v", paginator.Err())
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant