我正在尝试找出活动的保留实例列表。
aws ec2 describe-reserved-instances --filters "Name=instance-state-State,Values=active" --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value[]'
以上命令不起作用,我认为Name
字段不正确。
有帮助吗?
感谢
答案 0 :(得分:1)
aws ec2 describe-reserved-instances --filter Name=state,Values=active
--query 'ReservedInstances[*][InstanceType,InstanceCount]'
输出:
[
[
"m3.medium",
4
],
[
"c4.large",
5
]
]
答案 1 :(得分:1)
这是另一种看法。搜索
State == `active`
进入查询语句。输出还包括标签。顺便说一句,从查询周围的单引号更改为双引号(在mac上)将要求您使用反斜杠转义反引号。
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"
}
]