def add_pricing_info(instances): for i in instances: i.pricing = {} by_type = {i.instance_type: i for i in instances} ec2.add_pricing(by_type) # EBS cost surcharge as per https://aws.amazon.com/ec2/pricing/on-demand/#EBS-Optimized_Instances ebs_pricing_url = 'https://a0.awsstatic.com/pricing/1/ec2/pricing-ebs-optimized-instances.min.js' pricing = fetch_data(ebs_pricing_url) add_ebs_pricing(by_type, pricing)