Skip to content

Commit f03bf1e

Browse files
committed
fix price calculation for non-supported regions
1 parent b3f58e3 commit f03bf1e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

aws/reporting/ec2.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ def reformat_instance_data(raw_instances):
4040
region = re.sub(r'(\w+)-(\w+)-(\d)\w+', "\g<1>-\g<2>-\g<3>", inst["AvailabilityZone"])
4141
instance_type = inst['InstanceType']
4242
launch_time = inst['LaunchTime']
43-
inst['TotalBill'] = "${}".format(calculate_bill_for_instance(instance_type, region, launch_time)[2])
44-
inst['Cost Per Day'] = "${}".format(calculate_bill_for_instance(instance_type, region, launch_time)[1])
43+
try:
44+
inst['TotalBill'] = "${}".format(calculate_bill_for_instance(instance_type, region, launch_time)[2])
45+
except:
46+
inst['TotalBill'] = "$0"
47+
try:
48+
inst['Cost Per Day'] = "${}".format(calculate_bill_for_instance(instance_type, region, launch_time)[1])
49+
except:
50+
inst['Cost Per Day'] = "$0"
4551
return formatted_instances
4652

4753
def get_all_eips():

0 commit comments

Comments
 (0)