AWS cli –query – select tag by value not tab delimitated

AWS CLI text output not tab  delimited

When I was doing some basic outputting of data form the AWS cli, I noticed that the output was not on a single line.  It seems that when you query tags in the aws cli, the output is not tab delimited.  The tag value has a line return after it.  I had to figure out how to put all my returned variables on  a single line.  The arguments are tags, IPs, IDs, and  etc.  The tags made the output, unruly.

Using –query to select tag by value not tab delimitated

The solution is to add ‘| [0]’ to the end of a tags query such as

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[Tags[?Key==`Client`].Value | [0],Tags[?Key==`Environment`].Value | [0],Tags[?Key==`Name`].Value | [0],PublicIpAddress,PrivateIpAddress]' --output text