AWS [Amazon Web Services] provides compute, network, storage, and a lot of other cloud-based services.

We are using AWS EC2 instances to run custom, proprietary and infrastructure services.

If you have ever wonder, how easy, it is to export AWS EC2 Instances to Excel file… well, it’s as easy as copying and pasting.

But, this method works well if you only have few instances i.e. less than 50. AWS EC2 console limits the instance to 50 per page and doesn’t provide a method to export EC2 instance meta-data into csv file.

If you have large no. of instances, you might want to go AWS CLI way.

I am using a Windows 7 workstation to connect to AWS using CLI. Installation and configuration of AWS CLI are mentioned in this post.

The default output of “aws ec2 describe-instances” command is in JSON format and nowhere near the well-formatted CSV output.

We need to use some queries to get data in CSV format.

Launch you command prompt and issue the following command.

aws ec2 describe-instances --output text --query "Reservations[*].Instances[*].[InstanceId, InstanceType, ImageId, State.Name, LaunchTime, Placement.AvailabilityZone, Placement.Tenancy, PrivateIpAddress, PrivateDnsName, PublicDnsName, [Tags[?Key==`Name`].Value] [0][0], [Tags[?Key==`Role`].Value] [0][0], [Tags[?Key==`SysHostName`].Value] [0][0], [Tags[?Key==`Product`].Value] [0][0], [Tags[?Key==`Project`].Value] [0][0] ]" > I:\AllEC2Instances-1.csv


Some tags are specific to environment. You can either remove them or update the key value to get your custom tags.

You can add more filters if required, like VPC, Subnet, etc. The command structure is bit tricky, so you may want to refer to the JSON output to build the correct command.

Once you have the CSV file, Import it using Excel and you have the well formatted AWS EC2 Instance metadata in Excel.

Thanks to HFT Guy for pointers.

Hope this helps.