Boto EKS Code Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/eks.html =Internal= * Boto3 AWS SDK for Python ")
 
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
=Internal=
=Internal=
* [[Boto3 AWS SDK for Python#Code_Examples|Boto3 AWS SDK for Python ]]
* [[Boto3 AWS SDK for Python#Code_Examples|Boto3 AWS SDK for Python ]]
=List Clusters=
Lists the Amazon EKS clusters in the AWS account in the specified region.
<syntaxhighlight lang='py'>
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)
</syntaxhighlight>

Latest revision as of 04:49, 3 August 2022

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)