Problem scenario
You run an aws ec2 command and you get use the --filters flag with Name=VolumeId (consistent with the casing that you see in other AWS CLI contexts). You receive a message about "the filter VolumeId" being invalid. What should you do?
Solution
Use "volume-id" instead of "VolumeId".
In general we find that the syntax of the name itself, for an AWS CLI --filters flag, should be lowercase and hyphenated. We do not know why it is relatively undocumented. We find the hyphens are right before what would be medial captials of a given name.
You can use unfiltered output to see what is returned from a given AWS command. You can use the "." dot notation to drill into a given value that is nested in JSON with the nested key to the right of its parent.
Here you see VpcId nested inside of RequesterVpcInfo:
"RequesterVpcInfo": {
…
"VpcId": "vpc-123456",
To refer to the VPC ID itself for filtering purposes, you would use the following (e.g., with an 'aws ec2 desribe-vpc-peering-connections' command) dot notation as illustrated:
--filters Name=requester-vpc-info.vpc-id,Values=vpc-123456
You can add more restrictions by adding additional Name-Values pairs with a space after the above snippet. Here is an example:--filters Name=requester-vpc-info.vpc-id,Values=vpc-123456 Name=accepter-vpc-info.region,Values=us-west-2
Output would have to meet both the requirements of the VPC ID as vpc-123456 and the accepter VPC would have to be in the region us-west-2.