只想获取关于如何从AutoScalingGroups中仅获取此信息的专家提示:
awseb-e-ASG
实际JSON输出
{
"EnvironmentResources": {
"EnvironmentName": "MY-APP",
"AutoScalingGroups": [
{
"Name": "awseb-e-ASG"
}
],
"Triggers": [],
"LoadBalancers": [
{
"Name": "awseb-e-ELB"
}
],
"Queues": [],
"Instances": [
{
"Id": "i-XXXXXXXXXXXXXXXd"
}
],
"LaunchConfigurations": [
{
"Name": "awseb-e-LAUNCH"
}
]
}
}
我尝试了几个命令,但只能得到这个:
jq -r ".EnvironmentResources.LaunchConfigurations"
[
{
"Name": "awseb-e-ASG"
}
]
jq -r ".EnvironmentResources.LaunchConfigurations.Name"
jq: error: Cannot index array with string
答案 0 :(得分:0)
awseb-e-ASG
在.AutoScalingGroups
因此您可以使用以下过滤器:
.EnvironmentResources.AutoScalingGroups[].Name
通常要注意错误消息:
jq:错误:无法使用字符串索引数组
实际上,这是在告诉您.LaunchConfigurations.Name
是错误的,因为.LaunchConfigurations是一个数组,因此不能具有字符串值的键。