如何在aws-cli ec2命令中使用通配符? [英] How can I use wildcards in `aws-cli ec2` commands?
问题描述
我有一些EC2实例.我想使用 ec2 describe-instances
命令获取基于标签的特定值的实例列表.
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.
该表显示了我的用例.
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
所以我想以某种方式在ec2-describe-instances命令中使用通配符,以便获得预期的结果.
So I want to somehow use wildcard in the ec2-describe-instances command so that I get the expected outcome.
推荐答案
下面是一个示例,该示例如何根据标记的值过滤 ec2-describe-instances
的输出:>
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
此示例显示所有EC2实例的实例ID,其中"platform"标签设置为"windows".
This example shows the Instance ID for all EC2 instance with the "platform" tag set to a value of "windows".
在Values参数中也可以使用通配符(例如, Name = platform,Values = win *
).
Wildcards are also permitted in the Values parameter (eg Name=platform,Values=win*
).
这篇关于如何在aws-cli ec2命令中使用通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!