Boto EKS Code Example

From NovaOrdis Knowledge Base
Revision as of 04:49, 3 August 2022 by Ovidiu (talk | contribs) (→‎List Clusters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

Internal

List Clusters

Lists the Amazon EKS clusters in the AWS account in the specified region.

import boto3

client = boto3.client('eks')
cluster_names = []
max_results = 10
response = client.list_clusters(maxResults=max_results)
next_token = response.get('nextToken')
cluster_names.extend(response.get('clusters'))
while next_token:
  response = client.list_clusters(maxResults=max_results, nextToken=next_token)
  cluster_names.extend(response.get('clusters'))
  next_token = response.get('nextToken')
for cn in cluster_names:
  print(cn)