Skip to content

Commit e12f3fc

Browse files
authored
Fix EC2 scrape pricing script (#2100)
1 parent 909b8b0 commit e12f3fc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

contrib/scrape-ec2-prices.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ def scrape_ec2_pricing():
194194
skus[current_sku]["location"] = value
195195
# only get prices of compute instances atm
196196
elif (prefix, event) == (f"products.{current_sku}", "end_map"):
197-
if (
198-
"Compute Instance" not in skus[current_sku]["family"]
199-
and "Dedicated Host" not in skus[current_sku]["family"]
197+
family = skus[current_sku].get("family")
198+
199+
if family is None or (
200+
"Compute Instance" not in family and "Dedicated Host" not in family
200201
):
201202
del skus[current_sku]
202203

@@ -217,7 +218,7 @@ def scrape_ec2_pricing():
217218
if skus[sku]["locationType"] != "AWS Region":
218219
continue
219220
# skip any SQL
220-
if skus[sku]["preInstalledSw"] != "NA":
221+
if skus[sku].get("preInstalledSw") != "NA":
221222
continue
222223

223224
os = skus[sku]["os"]
@@ -318,7 +319,7 @@ def sort_key_by_numeric_other(key_value):
318319
def main():
319320
print(
320321
"Scraping EC2 pricing data (if this runs for the first time "
321-
"it has to download a 3GB file, depending on your bandwith "
322+
"it has to download a 7GB file, depending on your bandwith "
322323
"it might take a while)...."
323324
)
324325

0 commit comments

Comments
 (0)