0 votes
1 view
in AWS by (18.1k points)

How do I use AWS CLI to list all instances with name, state, instance size and AZ in the same line?

I got close with this:

aws ec2 describe-instances --query 'Reservations[].Instances[].[Tags[?Key==`Name`].Value[], Placement.AvailabilityZone,InstanceType,State.Name]' --output text

But that outputs the instance name below the rest. I want to keep them on the same line so I can copy to a spreadsheet.

1 Answer

0 votes
by (42.2k points)

Use this, it should work:

aws ec2 describe-instances --query 'Reservations[].Instances[].[Tags[?Key==`Name`].Value[] | [0], Placement.AvailabilityZone,InstanceType,State.Name]' --output text

...