Reputation: 511
I am trying to use aws cli command to filter based on volumetype and status with no name tag and additional tag something like below
aws ec2 describe-volumes --filters Name=volume-type,Values=gp2 Name=status,Values="available" --query 'Volumes[?!not_null(Tags[?Key == `Name`].Value,Tags[?Key == `Alias`].Value)]'
The above cli works but the notnull part is not applying to both the tags. Its only filtering volumes which doesnt have Tag as "Name" but it is still listing all the volumes which have the tag as "Alias"
I would like both of them(tagged as Name and Alias) NOT come up - basically
Well, based on this link : which is only filtering one tag
aws ec2 describe-volumes --filters Name=volume-type,Values=gp2 Name=status,Values="available" --query 'Volumes[?!not_null(Tags[?Key == `Name`]'
EDIT: trying to do something similar to describe snapshots with StartTime
aws ec2 describe-snapshots --owner-ids "***********" --query 'Snapshots[?!not_null(Tags[?Key == `Name`]) && !not_null(Tags[?Key == `Alias`]) && ?StartTime>=`2017-09-15`]'
Getting a error...Is it possible to provide a date range above?
Upvotes: 0
Views: 2124
Reputation: 53733
You can use JMESPath and
expression so writing something similar as
aws ec2 describe-volumes \
--filters Name=volume-type,Values=gp2 Name=status,Values="available" \
--query 'Volumes[?!not_null(Tags[?Key == `Name`]) && !not_null(Tags[?Key == `Alias`])]'
Upvotes: 1