Skip to content

Instantly share code, notes, and snippets.

@joshuabalduff
Created October 3, 2017 15:33
Show Gist options
  • Save joshuabalduff/3fa273527b48e22f348fc4d89b1a0b1f to your computer and use it in GitHub Desktop.
Save joshuabalduff/3fa273527b48e22f348fc4d89b1a0b1f to your computer and use it in GitHub Desktop.
AWS - Retreive All EC2 Instances w/ Info
#!/bin/bash
# AWS CLI to return all EC2 Data
#install AWS CLI
pip install awscli --upgrade --user
#Uncomment below to setup AWS IAM Keys
#aws configure
#Below command puts all instance details intto a .tsv which can be imorted to Excel as a csv with columns and rows
#Change key name to any other custom keys you want to output
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==`purpose`].Value] [0][0], [Tags[?Key==`environment`].Value] [0][0], [Tags[?Key==`name`].Value] [0][0] ]' > ec2_instances.tsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment