-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathec2-check.sh
executable file
·16 lines (14 loc) · 1006 Bytes
/
ec2-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
echo ""
echo "This script show you all the instances"
echo "in all the AWS available regions"
echo ""
for region in `aws ec2 describe-regions --output text | cut -f4`
do
echo -e "\nListing Instances in region: $region:"
echo "first check:..."
aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, "Launch time": .LaunchTime, Name: .Tags[].Value, "Instance Id": .InstanceId, "InstanceType": .InstanceType, Key: .KeyName, "Availability zone": .Placement.AvailabilityZone, "Private IP": .PrivateIpAddress, "Public Ip": .PublicIpAddress})'
# it there is no tag:
echo "second check:..."
aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, "Launch time": .LaunchTime, "Instance Id": .InstanceId, "InstanceType": .InstanceType, Key: .KeyName, "Availability zone": .Placement.AvailabilityZone, "Private IP": .PrivateIpAddress, "Public Ip": .PublicIpAddress})'
done