从名称获取AWS EMR集群ID

编程入门 行业动态 更新时间:2024-10-12 01:24:09
本文介绍了从名称获取AWS EMR集群ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

AWS CLI命令 aws emr list-clusters 返回以下json.是否可以通过bash或groovy来使用Name来获取ID?我不能只使用Id,因为我要删除群集并仅使用相同的名称来重建它们.因此,我知道集群的名称是"my-cluster",我想以某种方式使用它来获取集群的ID.最终的情况是我实际上想要群集的Master公共DNS.

AWS CLI command aws emr list-clusters returns the following json. Is there a way through bash or groovy that I can use the Name to get the Id? I can't just use the Id becauseI am deleting clusters and rebuilding them with only the same name. So I know the name of the cluster is "my-cluster" and I would like to use it somehow to get the Id of the cluster. End case is I actually want the Master public DNS of the cluster.

{ "Clusters": [ { "Status": { "Timeline": { "ReadyDateTime": 1433200405.353, "CreationDateTime": 1433199926.596 }, "State": "WAITING", "StateChangeReason": { "Message": "Waiting after step completed" } }, "NormalizedInstanceHours": 6, "Id": "j-3SD91U2E1L2QX", "Name": "my-cluster" }, { "Status": { "Timeline": { "ReadyDateTime": 1433200405.353, "CreationDateTime": 1433199926.596 }, "State": "WAITING", "StateChangeReason": { "Message": "Waiting after step completed" } }, "NormalizedInstanceHours": 6, "Id": "j-3S281UEK8L2LW", "Name": "my-cluster2" } ] }

推荐答案

您可以使用 query 参数来实现您要尝试的功能.该命令将如下所示:

You can use the query parameter to achieve what you are trying. The command will look like below:

aws emr list-clusters --query 'Clusters[?Name==`my-cluster`].Id' --output text

您可以找到 query 参数的完整文档此处.

You can find the complete documentation for the query parameter here.

更多推荐

从名称获取AWS EMR集群ID

本文发布于:2023-11-23 20:23:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622768.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:集群   名称   EMR   AWS   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!