I need an output similar to this:
{
"InstanceType": "c4.xlarge",
"PrivateIpAddress": "10.54.130.52",
"PlatformDetails": "Windows BYOL",
"State":
"Name": "running"
}
}
Reading the documentation of the jq
command I have reached the next output:
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"
}
}
Can anyone explain how to do that?
This should work:
aws ec2 describe-instances --instance-ids i-0079e143722b0b8f9 | jq -r '.Reservations[].Instances[] | {InstanceType, PrivateIpAddress, PlatformDetails, State: {Name:.State.Name} }'