aws ec2 describe-images state filter ignored when combined with name

810 views Asked by At

I want to use AWS CLI to return all my AMIs whose name starts with some string and whose state is "available", but the state filter seems to be ignored if I run

aws ec2 describe-images --owners self --filter Name=state,Values=available,Name=name,Values="Prod*"

This returns all AMIs that match by name, regardless of their state. Same if I separate the two filter arguments, like this:

aws ec2 describe-images --owners self --filter Name=state,Values=available --filter Name=name,Values="Prod*"

If I filter only by state it works as expected, e.g. this returns only available AMIs:

aws ec2 describe-images --owners self --filter Name=state,Values=available

How do I get the two filters to work together (as an AND)?

1

There are 1 answers

0
John Hanley On BEST ANSWER

This is how to describe multiple filters that AND the filter requirements.

aws ec2 describe-images --owners self --filter "Name=state,Values=available" "Name=name,Values=Prod*"