Amazon web services 如何在“aws cli ec2”命令中使用通配符?

Amazon web services 如何在“aws cli ec2”命令中使用通配符?,amazon-web-services,amazon-ec2,aws-cli,Amazon Web Services,Amazon Ec2,Aws Cli,我有一些EC2实例。我想使用ec2 descripe instances命令根据标记的特定值获取实例列表 该表显示了我的用例 Instance | Value (key:Purpose) | Outcome ----------+-------------------------+------------ InstanceA | Going | Filter InstanceB | Shopping,Going | Filter I

我有一些EC2实例。我想使用
ec2 descripe instances
命令根据标记的特定值获取实例列表

该表显示了我的用例

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 descripe instances命令中使用通配符,以便获得预期结果。

下面是一个示例,说明如何根据标记的值筛选
ec2 descripe instances的输出:

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --filters "Name=platform,Values=windows" --output text
此示例显示了所有EC2实例的实例ID,其中“platform”标记的值设置为“windows”


值参数中也允许使用通配符(例如
Name=platform,Values=win*
)。

您可以运行
ec2 descripe实例|grep-v关键字
从输出中排除注释的重新编码,但是我想使用AWS命令可用的-过滤器,并在其中使用通配符。非常感谢John,我正在尝试类似的东西:aws_cmd ec2 description instances--region$region--filter tag:Platform=$Platform\u id平台\u id是来自其他地方的参数…除了(*)通配符,我无法使用任何其他带有$Platform\u id的通配符。您的语法允许我这样做吗?我也会尝试一下。您可以这样做:Values=*$platform\u id*,但在以下情况下,这将失败:我只想获取具有目的的实例=现在,我在platform\u id中传递此值如果我执行$platform\u id,我将从表中获取所有实例,而我只需要InstanceA,B,C和D进行了筛选,因为只有它们的“Going”作为完整字符串,而不是字符串的一部分。希望我能把我的问题说清楚。是的。在这种情况下,请尝试使用不部分重叠的值。否则,你将不得不做一些后处理来应用更详细的逻辑(例如“去”而不是“不去”)。是的,这就是我作为救援的想法。然而,理想的情况是让标记值随我的喜好而变化。无论如何,谢谢你的时间和努力。干杯