AWS CLI 描述目标组

AWS CLI Describe Target Groups

haii,我有 awscli 结果将目标组描述为 json 格式

{
"TargetHealthDescriptions": [
    {
        "Target": {
            "Id": "1.1.1.1",
            "Port": 123,
            "AvailabilityZone": "ap-south-1"
        },
        "HealthCheckPort": "123",
        "TargetHealth": {
            "State": "healthy"
        }
    },
    {
        "Target": {
            "Id": "2.2.2.2",
            "Port": 123,
            "AvailabilityZone": "ap-south-1"
        },
        "HealthCheckPort": "123",
        "TargetHealth": {
            "State": "healthy"
        }
    }
]

}

我正在尝试制作一个 awscli 脚本来获得这样的结果

[
{
    "Id": "1.1.1.1",
    "Port": 123,
    "Health": null
},
{
    "Id": "2.2.2.2",
    "Port": 123,
    "Health": null
}

]

我尝试了几种查询方法,但在获取健康的空值时遇到问题,查询中有任何错误吗?

ex 查询

--query 'TargetHealthDescriptions[*].Target.{Id:Id, Port:Port, Health:TargetHealth.{state:State}}' --output json

试试下面的方法:

--query 'TargetHealthDescriptions[*].{Id:Target.Id,Port:Target.Port,Health:TargetHealth.State}'