erans / ec2instancespricing

Quick and dirty Python API and CLI to get EC2 instance pricing for On-Demand and Reserved Instances
Other
175 stars 89 forks source link

http://aws.amazon.com/ec2/pricing/json/linux-od.json deprecated? #15

Closed hyao closed 9 years ago

hyao commented 10 years ago

Hi,

Thanks a lot for writing a very useful tool!

As the title says, the url http://aws.amazon.com/ec2/pricing/json/linux-od.json now redirects to https://a0.awsstatic.com/pricing/1/deprecated/ec2/linux-od.json ?

On the ec2 pricing page, it uses something like for ec2 pricing data:

https://a0.awsstatic.com/pricing/1.0.19/ec2/linux-od.min.js

Maybe it's time to update to the new formats of pricing data for ec2?

Thanks a lot,

Heling

erans commented 10 years ago

Yes, I wanted to clear some time to do that. It seems the new format is not JSON, but a JS callback and the data is returned as a JS object (the annotation is not the same as JSON), so it will take me a while to find a reasonable way to parse it.

If it comes to it, I will write a parser just for that...

hyao commented 10 years ago

I did a quick test and am able to parse linux-od.js, and here's what I did:

  1. extract the price string from linux-od.js: the string that is the parameter to the callback function
  2. define the following vars: vers = "vers" rate = "rate" valueColumns = "valueColumns" currencies = "currencies" region = "region" vCPU = "vCPU" ECU = "ECU" memoryGiB = "memoryGiB" storageGB = "storageGB" USD = "USD" prices = "prices" name = "name" size = "size" sizes = "sizes" instanceTypes = "instanceTypes" regions = "regions" config = "config"
  3. d = eval(price_string)

Now d becomes a nice dict ready to use!

Thanks,

erans commented 10 years ago

Thanks. I wanted to see if I can avoid that parts so the code won't break every time a new field is added. I think I have something that is good enough since this is a minified JS file. I will try to commit it later.

hyao commented 10 years ago

Yeah, that makes sense. Thanks.

copernicus commented 10 years ago

They also seemed to have removed the pricing from that file for the older generation instances. So instance types like 'm2.2xlarge' are not in that file. That means that this pricing will no longer work for anyone that is using the previous generation type. Thats a bummer. Anyone know a workaround to get prices for the prev generation?

thanks!!

hyao commented 10 years ago

Maybe AWS tries to discourage the use of instance types from previous generations (they are only listed in the spot instance section on the ec2 pricing page: http://aws.amazon.com/ec2/pricing/), and I find current generation instance types more cost effective in general.

Thanks!

copernicus commented 10 years ago

I checked that too. Certainly looks like they prefer users to move to the current gen. They are slowly hiding away the info for the old gen instances :)

thanks

erans commented 9 years ago

There is a new version that I merged which works with the new format of files.