How can I use wildcards in `aws-cli ec2` commands?

Question:

I have some EC2 instances. I want to use the ec2 describe-instances command to get a list of instances based on a specific value of a tag.

The table shows my use-case.

So I want to somehow use wildcard in the ec2-describe-instances command so that I get the expected outcome.

Answer:

Here is an example of how to filter the output of ec2-describe-instances based on the value of a tag:

This example shows the Instance ID for all EC2 instance with the “platform” tag set to a value of “windows”.

Wildcards are also permitted in the Values parameter (eg Name=platform,Values=win*).

Leave a Reply