AWS CLI查找活动的预留实例列表 [英] AWS CLI to find out list of active reserved instances
本文介绍了AWS CLI查找活动的预留实例列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试找出活动的保留实例的列表.
I am trying to find out list of reserved instances that are active.
aws ec2 describe-reserved-instances --filters "Name=instance-state-State,Values=active" --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value[]'
上面的命令不起作用,我认为Name
字段不正确.
有什么帮助吗?
谢谢
The above command does not work, and I think the Name
field is not right.
Any help?
Thanks
推荐答案
这是另一种说法.搜索
State == `active`
进入查询语句.输出也包括标签.顺便说一句,从查询周围的单引号更改为双引号(在Mac上),将需要您使用反斜杠转义反引号.
into the query statement. The output includes labels as well. By the way, changing from single-quotes around the query to double-quotes (on a mac) will require you to escape the backticks with backslashes.
aws ec2 describe-reserved-instances --query 'ReservedInstances[?State == `active`].{Count: InstanceCount, Type: InstanceType}' --output json
输出:
[
{
"Count": 50,
"Type": "t2.medium"
},
{
"Count": 3,
"Type": "m4.2xlarge"
},
{
"Count": 17,
"Type": "m3.large"
},
{
"Count": 3,
"Type": "m3.2xlarge"
},
{
"Count": 2,
"Type": "m3.2xlarge"
},
{
"Count": 3,
"Type": "m3.xlarge"
},
{
"Count": 6,
"Type": "m4.4xlarge"
}
]
这篇关于AWS CLI查找活动的预留实例列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文