Export AWS EC2 Instance Data to CSV

This guide assumes you are using the AWS-CLI. You will need to install this first if you haven’t already.

[andy@pikedom ~]$ aws ec2 describe-instances --output text --query 'Reservations[*].Instances[*].[[Tags[?Key==`Name`].Value] [0][0], [Tags[?Key==`Purpose`].Value] [0][0], [Tags[?Key==`Team`].Value] [0][0], [Tags[?Key==`Owner`].Value] [0][0],InstanceId, InstanceType, ImageId, State.Name, LaunchTime, Placement.AvailabilityZone, Placement.TenAWS-CLIancy, PrivateIpAddress, PrivateDnsName, PublicDnsName]' > instances.csv

Here the first four columns pull in the tag information. This better allows me to track who is using what resources and for what purpose.

Be the first to comment

Leave a Reply