Boto EKS Code Example: Difference between revisions
Jump to navigation
Jump to search
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
=List Clusters= | =List Clusters= | ||
Lists the Amazon EKS clusters in the AWS account in the specified region. | 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)