Created
May 7, 2018 14:29
-
-
Save Gabriellpweb/167c253b7d0ca43e6e23921585dab91d to your computer and use it in GitHub Desktop.
List EC2 instances
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 | |
# | |
# USAGE: ec2ls sa-east-1 | |
# OUTPUT: | |
# Id ImageId Type PublicIp PrivateIp PrivateDNS | |
# i-0XX326X41X0254X25 ami-999X105X t2.small null 192.168.1.111 ip-192-168-1-111.sa-east-1.compute.internal | |
# | |
# | |
aws --region $1 ec2 describe-instances \ | |
| jq '.Reservations[].Instances[] | "\(.InstanceId) \(.ImageId) \(.InstanceType) \(.PublicIpAddress) \(.PrivateIpAddress) \(.PrivateDnsName)"' \ | |
| sed -e 's/\"//g' \ | |
| column -t -N Id,ImageId,Type,PublicIp,PrivateIp,PrivateDNS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment