Skip to content

Commit 652cb3b

Browse files
authored
Merge pull request #901 from 0xdabbad00/bug_fixes
Bug fixes in amis command
2 parents b484027 + 50e53e8 commit 652cb3b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

commands/amis.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,35 @@ def amis(args, accounts, config):
6060
)
6161
)
6262

63-
for region in listdir("data/aws/"):
63+
for region_name in listdir("data/aws/"):
6464
# Get public images
65-
public_images_file = "data/aws/{}/ec2-describe-images.json".format(region)
65+
public_images_file = "data/aws/{}/ec2-describe-images.json".format(region_name)
6666
public_images = json.load(open(public_images_file))
6767
resource_filter = ".Images[]"
6868
public_images = pyjq.all(resource_filter, public_images)
6969

7070
for account in accounts:
7171
account = Account(None, account)
72-
region = Region(account, {"RegionName": region})
72+
region = Region(account, {"RegionName": region_name})
7373

7474
instances = query_aws(account, "ec2-describe-instances", region)
7575
resource_filter = (
7676
'.Reservations[].Instances[] | select(.State.Name == "running")'
7777
)
7878
if args.instance_filter != "":
7979
resource_filter += "|{}".format(args.instance_filter)
80+
81+
if 'Reservations' not in instances:
82+
print(f"** skipping: {account.name} in {region_name}")
83+
continue
84+
8085
instances = pyjq.all(resource_filter, instances)
8186

8287
account_images = query_aws(account, "ec2-describe-images", region)
8388
resource_filter = ".Images[]"
89+
if 'Images' not in account_images:
90+
print(f"** skipping: {account.name} in {region_name}")
91+
continue
8492
account_images = pyjq.all(resource_filter, account_images)
8593

8694
for instance in instances:

commands/collect.py

+1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ def collect(arguments):
307307
# Services that will only be queried in the default_
308308
# TODO: Identify these from boto
309309
universal_services = [
310+
"account",
310311
"sts",
311312
"iam",
312313
"route53",

0 commit comments

Comments
 (0)