I am trying to list all cluster in aws ECS cluster using python boto3, it can only list 100 cluster maximum and i want 300 cluster

Viewed 558

session = boto3.Session()

client = session.client('ecs')

cluster = client.list_clusters()

clusterArns = cluster["clusterArns"]
print(clusterArns)
for i in clusterArns:
    print(i.split('/')[1])
1 Answers

The response will contain a nextToken if there are any additional pages of results.

If this is returned in a response you will need to run the client.list_clusters() passing in this parameter again to get the next page.

The MaxResults of a single page can only be between 1 and 100 so there is no way to increase the maximum items returned.

You can find out more about the list_clusters function from the documentation.

Related