简体   繁体   中英

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

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.

Instance  | Value (key:Purpose)     | Outcome
----------+-------------------------+------------
InstanceA | Going                   | Filter
InstanceB | Shopping,Going          | Filter
InstanceC | Going,Shoping           | Filter
InstanceD | Shopping,Going,Chatting | Filter
InstanceE | GoingGreat              | DONT Filter
InstanceF | NotGoing                | DONT Filter

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

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

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --filters "Name=platform,Values=windows" --output text

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* ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM