|
@@ -158,19 +158,23 @@ if __name__ == "__main__":
|
|
|
exclude_state="stopped"
|
|
|
|
|
|
instances[p] = list()
|
|
|
- for instance in gather_instances(ec2[p], args.tagname, args.tagvalue, exclude_state):
|
|
|
- if args.instancename:
|
|
|
- # At least one instance name was specified, so go through and match
|
|
|
- for i in args.instancename:
|
|
|
- if fnmatch.fnmatch(instance['name'], i):
|
|
|
- print(f'{p:<30}\t{ instance["instance_id"] }\t{instance["state"]:<10}\t{instance["name"]}')
|
|
|
- instances[p].append(instance['instance_id'])
|
|
|
- instance_count += 1
|
|
|
- else:
|
|
|
- # No instance name specified, we add everything
|
|
|
- print(f'{p:<30}\t{ instance["instance_id"] }\t{instance["state"]:<10}\t{instance["name"]}')
|
|
|
- instances[p].append(instance['instance_id'])
|
|
|
- instance_count += 1
|
|
|
+ try:
|
|
|
+ for instance in gather_instances(ec2[p], args.tagname, args.tagvalue, exclude_state):
|
|
|
+ if args.instancename:
|
|
|
+ # At least one instance name was specified, so go through and match
|
|
|
+ for i in args.instancename:
|
|
|
+ if fnmatch.fnmatch(instance['name'], i):
|
|
|
+ print(f'{p:<30}\t{ instance["instance_id"] }\t{instance["state"]:<10}\t{instance["name"]}')
|
|
|
+ instances[p].append(instance['instance_id'])
|
|
|
+ instance_count += 1
|
|
|
+ else:
|
|
|
+ # No instance name specified, we add everything
|
|
|
+ print(f'{p:<30}\t{ instance["instance_id"] }\t{instance["state"]:<10}\t{instance["name"]}')
|
|
|
+ instances[p].append(instance['instance_id'])
|
|
|
+ instance_count += 1
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f'Could not enumerate instances in profile "{p}": {e}')
|
|
|
+ profiles.remove(p)
|
|
|
|
|
|
if instance_count == 0:
|
|
|
print('')
|