Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS CLI以查找活动保留实例的列表_Amazon Web Services_Amazon Ec2_Aws Cli - Fatal编程技术网

Amazon web services AWS CLI以查找活动保留实例的列表

Amazon web services AWS CLI以查找活动保留实例的列表,amazon-web-services,amazon-ec2,aws-cli,Amazon Web Services,Amazon Ec2,Aws Cli,我正在试图找出活动的保留实例列表 aws ec2 describe-reserved-instances --filters "Name=instance-state-State,Values=active" --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value[]' 上面的命令不起作用,我认为Name字段不正确。 有什么帮助吗? 谢谢 输出: [ [ "m3.medium", 4

我正在试图找出活动的保留实例列表

aws ec2 describe-reserved-instances --filters  "Name=instance-state-State,Values=active" --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value[]'
上面的命令不起作用,我认为
Name
字段不正确。 有什么帮助吗? 谢谢

输出:

[
    [
        "m3.medium",
        4
    ],
    [
        "c4.large",
        5
    ]
]
[
    {
        "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"
    }
]
输出:

[
    [
        "m3.medium",
        4
    ],
    [
        "c4.large",
        5
    ]
]
[
    {
        "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"
    }
]

这是另一种看法。搜索

State == `active`
进入查询语句。输出还包括标签。顺便说一下,将查询中的单引号改为双引号(在mac上)将需要使用反斜杠来转义反斜杠

aws ec2 describe-reserved-instances --query 'ReservedInstances[?State == `active`].{Count: InstanceCount, Type: InstanceType}' --output json
输出:

[
    [
        "m3.medium",
        4
    ],
    [
        "c4.large",
        5
    ]
]
[
    {
        "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"
    }
]

这是另一种看法。搜索

State == `active`
进入查询语句。输出还包括标签。顺便说一下,将查询中的单引号改为双引号(在mac上)将需要使用反斜杠来转义反斜杠

aws ec2 describe-reserved-instances --query 'ReservedInstances[?State == `active`].{Count: InstanceCount, Type: InstanceType}' --output json
输出:

[
    [
        "m3.medium",
        4
    ],
    [
        "c4.large",
        5
    ]
]
[
    {
        "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 ec2描述保留实例--filters Name=state,Values=active
但我如何才能只获取实例计数的实例类型?我找出了问题的一部分:
aws ec2描述保留实例--filters Name=state,Values=active
但如何仅获取实例计数的实例类型?