What is the correct tag filtering syntax in the -vpcs description?

I am trying to understand the aws ec2 cli call. I want to describe all the VPCs, then filer, to a user tag (vpcname = myvpc, however after trying several combinations, I continue to get conflicting errors regarding the format and use of -filters. Using as a link [ http://docs.aws.amazon.com /cli/latest/reference/ec2/describe-vpcs.html†[1]

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

however this returns

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

so try

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

and he returns

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

so try a few other combinations

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 tips on how I format this query?

+4
2

- , -vpcs. , :

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

, Name=string1,Values=string1..., :

  • = : TagName
  • = TagValue

, :

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

TAG VALUE:

TAG=vpcname
VALUE=myvpc
aws ec2 describe-vpcs |\
jq -r ".Vpcs[] | select (.Tags[] | select(.Key==\"$TAG\") |\
select(.Value==\"$VALUE\"))"
0

All Articles