|
@@ -5,8 +5,7 @@
|
|
|
# Unbuffered, no CRLF print:
|
|
|
from __future__ import print_function
|
|
|
import sys, os
|
|
|
-import boto3
|
|
|
-import boto3.session
|
|
|
+import boto3, boto3.session, botocore
|
|
|
import threading # We may not do it yet, but developing with threadsafe in mind, as best I can
|
|
|
|
|
|
try:
|
|
@@ -63,15 +62,19 @@ for region in regions:
|
|
|
ec2 = boto3.client('ec2', region_name=region)
|
|
|
try:
|
|
|
instance = ec2.describe_instances(InstanceIds=[ SEARCHSTRING ])
|
|
|
- FOUND=FOUND+1
|
|
|
- if DEBUG >= 2:
|
|
|
- print("FOUND in profile '" + PROFILE + "', Region: '" + region + "'")
|
|
|
- if FOUND > 1:
|
|
|
- FOUNDSTR = FOUNDSTR + "\n"
|
|
|
- FOUNDSTR = FOUNDSTR + "FOUND in profile '" + PROFILE + "', Region: '" + region
|
|
|
- except:
|
|
|
- if DEBUG >= 2:
|
|
|
- print("Not found in profile '" + PROFILE + "', Region: '" + region + "'")
|
|
|
+ except botocore.exceptions.ClientError:
|
|
|
+ # Not Found
|
|
|
+ continue
|
|
|
+
|
|
|
+ FOUND=FOUND+1
|
|
|
+ if DEBUG >= 2:
|
|
|
+ print("FOUND in profile '" + PROFILE + "', Region: '" + region + "'")
|
|
|
+ if FOUND > 1:
|
|
|
+ FOUNDSTR = FOUNDSTR + "\n"
|
|
|
+ for r in instance['Reservations']:
|
|
|
+ for i in r['Instances']:
|
|
|
+ FOUNDSTR = "FOUND\t" + PROFILE + "\t" + region + "\t" + i['InstanceId']
|
|
|
+
|
|
|
# End of for region
|
|
|
if DEBUG == 1:
|
|
|
print(".")
|
|
@@ -85,6 +88,6 @@ if FOUND > 0:
|
|
|
exit(0)
|
|
|
else:
|
|
|
if DEBUG == 1:
|
|
|
- print("Not found.")
|
|
|
+ print("notfound")
|
|
|
exit(255)
|
|
|
|