在describe-vpcs中按标签过滤的正确语法是什么?

 mobiledu2502900917 发布于 2022-12-10 11:40

我想了解一个aws ec2 cli电话.我想在自定义标签上描述所有VPC然后文件管理器(vpcname = myvpc,但是在尝试多种组合后,我不断得到关于格式和使用--filters的冲突错误.使用作为参考[ http://docs.aws .amazon.com/CLI /最新/参考/ EC2 /描述-vpcs.html] [1]

aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filters vpcname,myvpc

然而这又回来了

Error parsing parameter '--filters': should be: Key value pairs, where values are separated by commas, and multiple pairs are separated by spaces.
--filters Name=string1,Values=string1,string2 Name=string1,Values=string1,string2

这么努力

aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filters Name = vpcname,Values = myvpc

然后它回来了

A client error (InvalidParameterValue) occurred when calling the DescribeVpcs operation: The filter 'vpcname' is invalid

所以尝试其他一些组合

aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filters tag :Name=vpcname,Values=myvpc

Error parsing parameter '--filters': should be: Key value pairs, where values are separated by commas, and multiple pairs are separated by spaces.
--filters Name=string1,Values=string1,string2 Name=string1,Values=string1,string2

关于如何格式化此请求的任何建议?

1 个回答
  • 你已经非常接近解决它 - 唯一的问题是你没有为describe-vpcs指定一个有效的过滤器.这是与您的用例相关的过滤器:

    tag:key=*value* - The key/value combination of a tag assigned to the resource.
    

    因此,当它要求时Name=string1,Values=string1...,它期望:

    NAME =标签:标签名

    值= TagValue

    试试这个,在我的本地使用不同的自定义标签:

    aws ec2 describe-vpcs --filters Name=tag:vpcname,Values=myvpc
    

    2022-12-11 02:58 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有