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

art*_*lay 8 amazon-ec2 amazon-web-services amazon-vpc aws-cli

我想了解一个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
Run Code Online (Sandbox Code Playgroud)

这么努力

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
Run Code Online (Sandbox Code Playgroud)

所以尝试其他一些组合

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
Run Code Online (Sandbox Code Playgroud)

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

Ant*_*ace 19

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

tag:key=*value* - The key/value combination of a tag assigned to the resource.
Run Code Online (Sandbox Code Playgroud)

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

  • NAME =标签:标签名
  • 值= TagValue

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

aws ec2 describe-vpcs --filters Name=tag:vpcname,Values=myvpc
Run Code Online (Sandbox Code Playgroud)