AWS列表实例正在使用一个CLI呼叫进行待处理和运行
我有一个应用程序需要知道我在待处理
和运行
状态中都有多少个EC2实例。我可以运行以下两个命令并将它们总结以获取结果,但这意味着我的awscli
将提出两个请求,这既是缓慢的,又可能是不良的练习。
aws ec2 describe-instances \
--filters Name=instance-state-name,Values="running" \
--query 'Reservations[*].Instances[*].[InstanceId]' \
--output text \
| wc -l
aws ec2 describe-instances \
--filters Name=instance-state-name,Values="pending" \
--query 'Reservations[*].Instances[*].[InstanceId]' \
--output text \
| wc -l
是否有一种方法将这两个查询组合到一个查询中,或者有另一种使用单个查询的待处理 + 运行
实例的方法?
干杯!
I have an application which needs to know how many EC2 instances I have in both the pending
and running
states. I could run the two following commands and sum them to get the result, but that means my awscli
will be making two requests, which is both slow and probably bad practice.
aws ec2 describe-instances \
--filters Name=instance-state-name,Values="running" \
--query 'Reservations[*].Instances[*].[InstanceId]' \
--output text \
| wc -l
aws ec2 describe-instances \
--filters Name=instance-state-name,Values="pending" \
--query 'Reservations[*].Instances[*].[InstanceId]' \
--output text \
| wc -l
Is there a way of combining these two queries into a single one, or another way of getting the total pending
+ running
instances using a single query?
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
shorthand syntax :
Shorthand syntax with commas:
您可以添加几个过滤器值,如下所示:
You can add several filter values as follows: