将 ListSteps 与 AWS SDK 或 CLI 配合使用 - AWS SDK 代码示例

AWS 文档 SDK 示例 GitHub 存储库中还有更多 AWS SDK 示例。

ListSteps 与 AWS SDK 或 CLI 配合使用

以下代码示例演示如何使用 ListSteps

CLI
AWS CLI

以下命令列出了集群 ID 为 j-3SD91U2E1L2QX 的集群的所有步骤:

aws emr list-steps --cluster-id j-3SD91U2E1L2QX
  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListSteps

Python
适用于 Python 的 SDK (Boto3)
注意

查看 GitHub,了解更多信息。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

def list_steps(cluster_id, emr_client): """ Gets a list of steps for the specified cluster. In this example, all steps are returned, including completed and failed steps. :param cluster_id: The ID of the cluster. :param emr_client: The Boto3 EMR client object. :return: The list of steps for the specified cluster. """ try: response = emr_client.list_steps(ClusterId=cluster_id) steps = response["Steps"] logger.info("Got %s steps for cluster %s.", len(steps), cluster_id) except ClientError: logger.exception("Couldn't get steps for cluster %s.", cluster_id) raise else: return steps
  • 有关 API 详细信息,请参阅《AWS SDK for Python (Boto3) API Reference》中的 ListSteps