本文介绍了在 describe-vpcs 中按标签过滤的正确语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解 aws ec2 cli 调用.我希望在自定义标签上描述所有 VPC,然后是过滤器(vpcname=myvpc,但是在尝试多种组合后,我不断收到有关 --filters 的格式和使用的冲突错误.用作参考 [http://docs.aws.amazon.com/cli/latest/参考/ec2/describe-vpcs.html][1]

I am trying to understand a aws ec2 cli call. I am looking to describe all VPC then filer on a custom tag (vpcname=myvpc, however after trying multiple combinations I keep getting conflicting errors about the format and use of --filters. using as a reference [http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-vpcs.html][1]

aws --profile myProfile --region eu-west-1 ec2 describe-vpcs --filtersvpcname,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名称=vpcname,值=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

关于我如何格式化这个请求有什么建议吗?

Any advice on how I format this request?

推荐答案

您已经接近解决它了——唯一的问题是您没有指定 描述-vpcs 的有效过滤器.以下是与您的用例相关的过滤器:

You got pretty close to solving it -- the only problem is that you are not specifying a valid filter for describe-vpcs. Here's the filter that would be relevant to your use case:

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

所以当它要求 Name=string1,Values=string1... 时,它期望:

So when it is asking for Name=string1,Values=string1..., it expects:

  • 名称=标签:标签名称
  • 值=标签值

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

Try this instead, works for me locally with a different custom tag:

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

这篇关于在 describe-vpcs 中按标签过滤的正确语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 07:59