【问题标题】:How do I get the server name with aws ec2 describe-instances如何使用 aws ec2 describe-instances 获取服务器名称
【发布时间】:2014-09-18 21:28:41
【问题描述】:

我能够将实例 ID、实例类型和公共 IP 地址转换为表格格式。但我无法解析标签名称。我们为所有服务器插入名称,以便更容易识别。

这是我迄今为止提出的一个示例

aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,InstanceType,PublicIpAddress]' --output table

------------------------------------------------
|               DescribeInstances              |
+------------+-------------+-------------------+
|  i-64629700|  m1.small   |  54.227.243.165   |
|  i-2d300249|  m3.xlarge  |  23.23.166.230    |
|  i-7422c909|  m1.small   |  23.21.105.175    |
|  i-08c76e24|  m3.xlarge  |  54.235.253.163   |
|  i-99a20a72|  m3.medium  |  23.23.184.200    |
|  i-6053991b|  m1.large   |  54.221.250.189   |

不知道如何在表格中添加这样的内容

'Reservations[].Instances[].Tags[?Key==`Name`].Value[]'

【问题讨论】:

    标签: amazon-web-services amazon-ec2 command-line-interface


    【解决方案1】:

    你很亲密。试试这个:

    aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,InstanceType,PublicIpAddress,Tags[?Key==`Name`]| [0].Value]' --output table
    

    【讨论】:

    • 我修复了命令。当我最初运行它时,括号太多了。谢谢。
    猜你喜欢
    • 2023-03-03
    • 2022-06-24
    • 1970-01-01
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    相关资源
    最近更新 更多