我正在尝试使用 boto3 列出 EMR 上的所有活动集群,但我的代码似乎不起作用,它只是返回 null。
我正在尝试使用 boto3 来做到这一点
1) 列出所有活动的EMR集群
aws emr list-clusters --active
2) 仅列出集群 ID 和活动集群的名称集群名称
aws emr list-clusters --active --query "Clusters[*].{Name:Name}" --output text
集群 ID
aws emr list-clusters --active --query "Clusters[*].{ClusterId:Id}" --output text
但我在使用 boto3 的起始阶段受阻
import boto3
client = boto3.client("emr")
response = client.list_clusters(
ClusterStates=[
'STARTING',
],
)
print response
有什么建议我如何将这些 CLI 命令转换为 boto3
Thanks
以下代码可以打印活动的 emr 名称和 id:
import boto3
client = boto3.client("emr")
response = client.list_clusters(
ClusterStates=[
'STARTING', 'BOOTSTRAPPING', 'RUNNING', 'WAITING', 'TERMINATING'
]
)
for cluster in response['Clusters']:
print(cluster['Name'])
print(cluster['Id'])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)