The closest I have get is using the following commands.
This command manage to lists all name of instances.
aws ec2 describe-instances --filters Name=vpc-id,Values=vpc-e2f17e8b --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value[]'
This command manage to list all private ip address, instance id and ALL tags which I don't need. I just need the name.
aws ec2 describe-instances --filters Name=vpc-id,Values=vpc-e2f17e8b | jq '.Reservations[].Instances[] | {PrivateIpAddress, InstanceId, Tags}'
I'm not sure why I can't execute command like this way:
aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.PrivateIpAddress + " " + .InstanceId + " " + .Tags[?Key==`Name`].Value[]'
This command works but its showing all the Tags Key names.
aws ec2 describe-instances | jq '.["Reservations"]|.[]|.Instances|.[]|.PrivateIpAddress + " " + .InstanceId + " " + .Tags'
Name
].Value[]" as a filter for Key Name Value output is only possible after aws-cli v1.3.0. And I'm using a combination of --filter and jq to get the output I want. The closest command is aws ec2 describe-instances --filters Name=vpc-id,Values=vpc-e2f17e8b | jq '.Reservations[].Instances[] | {PrivateIpAddress, InstanceId, Tags}' I just need to know how to reference the Tag Key=Name using jq.