Created
May 14, 2020 19:10
-
-
Save ahamez/d988635725cf4307f6f1abfd9f8a7a8f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# install aws cli first and configure it with credentials and default region | |
# the script will iterate over all regions of AWS | |
#! /bin/sh | |
for region in `aws ec2 describe-regions --output text | cut -f4` | |
do | |
echo -e "\nListing Instances in region:'$region'..." | |
# aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table --region $region | |
aws --region $region 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==`team`].Value] [0][0] ]' >> instances.csv | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment