Skip to content

Export EC2 Instance List

0

I'm in EC2 Dashboard - Instances. After pulling up my list of instances I can see several are over provisioned. With hundreds of instances, I'd like to export the findings. I can't find a solution. There is a possible one but it's in Japanese.

asked 3 years ago13.3K views

2 Answers
1

Hi Jon

Would the AWS CLI work for you? aws ec2 describe-instances? You can then save it to CSV by adding --output text >> instances.csv

Documentation here: https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html

Cheers James

answered 3 years ago

AWS
EXPERT

reviewed 3 years ago

  • I'm not familiar with working in CLI. I reviewed the document, which confused me, and not sure how to proceed. I need to see a complete list of all instances and I'm also looking for more detailed information within them. I noticed several right off the bat were not configured properly. They were not optimized. Rather than one by one through 150+ instances, I hoped to just get a read out or even a full lists that included details like that so I can filter out.

  • I've not tried this, but perhaps this blog post may help you out? https://www.iocloud.blog/2020/07/03/how-to-export-ec2-instances-to-csv-excel-using-aws-systems-manager-explorer/

    Otherwise, the CLI is the easiest way I know to get a list.

0

Try this aws ec2 describe-instances --query Reservations[*].Instances[*].[InstanceId,InstanceType,PlatformDetails] --output text which would give you the bare bones that you want.

You can use the --output table option to display it as a more aesthetically pleasing table:

aws ec2 describe-instances --query Reservations[*].Instances[*].[InstanceId,InstanceType,PlatformDetails] --output table

Output it as JSON and then add some jq magic and you get CSV output that can more easily be parsed, or imported into a spreadsheet:

aws ec2 describe-instances --query Reservations[*].Instances[*].[InstanceId,InstanceType,PlatformDetails] --output json | jq -r '.[][] | @csv'
EXPERT

answered 3 years ago

  • I'm not familiar enough with CLI or JSON to perform this task. My primary role is project management, cost management.

  • Fair enough, in that case I think probably the link in @James-Malcolm's comment is the best way to go.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.