如何获取与特定名称与boto3匹配的AWS EMR群集I列表?
我在这里有这个代码:
import sys
import time
import boto3
client = boto3.client("emr")
cluster_name = 'Adhoc-CSDP-EMR'
response = client.list_clusters(
ClusterStates=[
'RUNNING', 'WAITING'
]
)
for cluster in response['Clusters']:
print(cluster['Name'])
print(cluster['Id'])这将打印所有处于运行或等待状态的集群。如何过滤与cluster_name匹配的结果?
发布于 2020-04-29 11:02:29
嗯,为什么我们不能这样做呢?
matching_cluster_ids = list()
for cluster in response['Clusters']:
if cluster_name == cluster['Name']:
matching_cluster_ids.append(cluster['Id'])稍后,如果需要,您可以对任何匹配的cluster_ids执行describe_cluster() (或任何其他操作)。
https://stackoverflow.com/questions/61488242
复制相似问题