I am trying to run the ec2 describe-instances command and output as table sorted by PrivateIPAddress.
I tried this command.
aws ec2 describe-instances \
--instance-id $instances
--region us-west-2
--output table
--query 'Reservations[].Instances[].{LaunchTime:LaunchTime,InstanceId:InstanceId,PrivateIpAddress:PrivateIpAddress,Name:Tags[?Key==`Name`] | [0].Value, Status:State.Name} | sort_by(@, &[2])'
It fails with this error
In function sort_by(), invalid type for value: {'LaunchTime': '2023-05-04T08:10:46+00:00', 'InstanceId': 'i-23424242424234234aef', 'PrivateIpAddress': 'xx.xxx'.xx.xxx, 'Name': 'sdkjsdfk', 'Status': 'running'}, expected one of: ['string', 'number'], received: "null"
What am I doing wrong?