我正在尝试了解 aws ec2 cli 调用。我希望在自定义标签上描述所有 VPC,然后是文件管理器(vpcname=myvpc,但是在尝试多种组合后,我不断收到有关 --filters 的格式和使用的冲突错误。用作引用 [http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-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
关于如何格式化此请求的任何建议?
最佳答案
你已经很接近解决它了——唯一的问题是你没有指定 valid filter for describe-vpcs .这是与您的用例相关的过滤器:
tag:key=*value* - The key/value combination of a tag assigned to the resource.
所以当它要求
Name=string1,Values=string1...
,它期望:试试这个,使用不同的自定义标签在本地为我工作:
aws ec2 describe-vpcs --filters Name=tag:vpcname,Values=myvpc
关于amazon-web-services - 在 describe-vpcs 中按标签过滤的正确语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27057932/