Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (19.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 (44.4k points)
edited by

Use this, it should work:

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

Want more insights on AWS, visit the AWS Training page. 

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...