【问题标题】:Describe-Volume AWS CLI command描述卷 AWS CLI 命令
【发布时间】:2019-01-28 21:05:44
【问题描述】:

我正在使用 cygwin 终端在我的计算机上使用 AWS CLI,并且我正在尝试输出查询文本来描述我的 EC2 环境的卷。 cli 命令可以正常工作,但是输出到 tsv 文件的文本文件会导致文档格式错误。

我正在使用的 aws cli 命令是:

aws ec2 describe-volumes --region $REGION --query 'Volumes[*].[Attachments[].{VolumeID:VolumeId,InstanceID:InstanceId},AvailabilityZone]' --output text >> Volumes_In_AWS.tsv

This is what the text file outprints onto the tsv file.

我试图将 region/az 与 instanceid 和 volumeid 放在同一行,但输出文本似乎将其表示为新行。

有没有办法使用这个 cli 命令将文本输出到同一行?

谢谢!

【问题讨论】:

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


    【解决方案1】:

    问题是 Volume 和 AZ 之间是一对一的映射,而 Volume 和 Attachment 之间是一对多的映射。

    如果你假设一个附件,那么你可以使用:

    aws ec2 describe-volumes --query 'Volumes[*].[VolumeId, AvailabilityZone,Attachments[0].InstanceId]' --output text
    

    这会导致:

    vol-387e4630    ap-southeast-2a i-0ef635853b22f705e
    vol-6896efa2    ap-southeast-2b i-0c9c9b94b5583afdc
    

    【讨论】:

    • 非常感谢!这就像一个魅力。我不认为 1 到 1/ 1 到多映射是我出错的地方。非常感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多