Created
October 3, 2017 15:33
-
-
Save joshuabalduff/3fa273527b48e22f348fc4d89b1a0b1f to your computer and use it in GitHub Desktop.
AWS - Retreive All EC2 Instances w/ Info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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