【发布时间】:2019-07-07 17:42:26
【问题描述】:
我正在尝试使用 boto3 列出 EMR 上的所有活动集群,但我的代码似乎无法正常工作,它只是返回 null。
我正在尝试使用 boto3 来做到这一点
1) 列出所有 Active EMR 集群
aws emr list-clusters --active
2) 仅列出集群 id 和 Active 的名称 集群名称
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
谢谢
【问题讨论】:
-
你是怎么被屏蔽的? CLI 的 --active 的 boto3 等效项可能类似于 ClusterStates=['STARTING', 'BOOTSTRAPPING', 'RUNNING', 'WAITING', 'TERMINATING']。
-
您可能只想获取完整的集群列表(没有过滤器),然后在代码中缩小列表范围。
标签: python amazon-web-services boto3