Closed pablodo closed 8 years ago
I noticed this with a different instance type.
The JavaScript files referenced by the AWS Pricing pages have changed once again, as Amazon recently announced a revised pricing structure for their Reserved Instances. Light and Medium Utilization reserved instances will be deprecated in early 2015. There is now a 'No Upfront' (in addition to 'Partial Upfront' and 'All Upfront') rate structure for RI.
I believe the data is now spread across the following pages. I have not had time to look into this any further, but I want to document these links, in case someone else has time.
http://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js http://a0.awsstatic.com/pricing/1/ec2/rhel-od.min.js http://a0.awsstatic.com/pricing/1/ec2/sles-od.min.js http://a0.awsstatic.com/pricing/1/ec2/mswin-od.min.js http://a0.awsstatic.com/pricing/1/ec2/mswinSQL-od.min.js http://a0.awsstatic.com/pricing/1/ec2/mswinSQLWeb-od.min.js
http://a0.awsstatic.com/pricing/1/ec2/previous-generation/linux-od.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/rhel-od.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/sles-od.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/mswin-od.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/mswinSQL-od.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/mswinSQLWeb-od.min.js
http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/ri-v2/red-hat-enterprise-linux-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/ri-v2/suse-linux-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/ri-v2/windows-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/ri-v2/windows-with-sql-server-standard-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/ri-v2/windows-with-sql-server-web-shared.min.js
http://a0.awsstatic.com/pricing/1/ec2/previous-generation/ri-v2/linux-unix-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/ri-v2/red-hat-enterprise-linux-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/ri-v2/suse-linux-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/ri-v2/windows-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/ri-v2/windows-with-sql-server-standard-shared.min.js http://a0.awsstatic.com/pricing/1/ec2/previous-generation/ri-v2/windows-with-sql-server-web-shared.min.js
I just needed the price for on-demand instances, so I found the same links, and used this regex to get the data:
remove_callback_regex = re.compile(r'callback\((.+?)\);')
quote_regex = re.compile(r'(\w+):')
response = urllib2.urlopen(url)
result = response.read()
match = remove_callback_regex.search(result)
if match:
quoted = quote_regex.sub(r'"\1":', match.group(1))
data = json.loads(quoted)
Maybe this will help you to implement those java script in the future.
The code should be using the newer JSONs now so it should be ok. Give it a try.
I'm looking for the prices for
ondemand
,us-east-1
,linux
,m3.2xlarge
. In the page, it says that the price is $0.560:But when I run the script like this:
./ec2instancespricing.py --type ondemand --filter-region us-east-1 --filter-type 'm3.2xlarge' --filter-os-type 'linux' --format json
The output is:
{"regions": [{"region": "us-east-1", "instanceTypes": [{"os": "linux", "price": 0.9, "type": "m3.2xlarge"}]}], "config": {"currency": "USD", "unit": "perhr"}}
I think the problem is that the API may be deprecated. If you make a request to http://aws.amazon.com/ec2/pricing/pricing-on-demand-instances.json, you will see that it redirects to a deprecated API.