我需要类似这样的输出:
{
"InstanceType": "c4.xlarge",
"PrivateIpAddress": "10.54.130.52",
"PlatformDetails": "Windows BYOL",
"State":
"Name": "running"
}
}
阅读
jq
命令的文档我已经达到了下一个输出:
aws ec2 describe-instances --instance-ids i-0079e143722b0b8f9 | jq -r '.Reservations[].Instances[] | {InstanceType, PrivateIpAddress, PlatformDetails, State}'
{
"InstanceType": "c4.xlarge",
"PrivateIpAddress": "10.54.130.52",
"PlatformDetails": "Windows BYOL",
"State": {
"Code": 16,
"Name": "running"
}
}
谁能解释一下该怎么做?
这应该有效:
aws ec2 describe-instances --instance-ids i-0079e143722b0b8f9 | jq -r '.Reservations[].Instances[] | {InstanceType, PrivateIpAddress, PlatformDetails, State: {Name:.State.Name} }'