-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws-ls
More file actions
executable file
·17 lines (15 loc) · 800 Bytes
/
Copy pathaws-ls
File metadata and controls
executable file
·17 lines (15 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash
# vi: ft=sh
regions=$(aws ec2 describe-regions | grep RegionName | awk '{print $2}' | tr -d '"')
for region in $regions; do
servers=$(aws ec2 describe-instances --region $region)
for (( i = 0; ; i++ )); do
name=$(echo $servers | python -c 'import sys, json; print json.load(sys.stdin)["Reservations"]['$i']["Instances"][0]["Tags"][0]["Value"]' 2> /dev/null)
if [[ -z $name ]]; then
break
fi
dns=$(echo $servers | python -c 'import sys, json; print json.load(sys.stdin)["Reservations"]['$i']["Instances"][0]["PublicDnsName"]')
state=$(echo $servers | python -c 'import sys, json; print json.load(sys.stdin)["Reservations"]['$i']["Instances"][0]["State"]["Name"]')
echo "$region $name $dns $state"
done
done