1

I need to implement a solution to get the Amazon instance hourly cost for each pricing model (on-demand, reserved, spot instance with predefined duration and spot instance with non-predefined duration).

I have downloaded the file from AWS Price List API to get on-demand and reserved informations about instance.But the file is to big and complicated for treatment. Also i uses the AWS Command-Line Interface (CLI) to get the informations about SpotInstance and it was perfectly what i need.

Is there a solution with the AWS Command-Line Interface (CLI) to get the other two types (on demand and reserved instances)? If yes, what are the command to get it.If not, does anyone had already did the treatment with the file and how? Thank you for your help.

Imen Neji
  • 41
  • 3

1 Answers1

0

The AWS Command-Line Interface (CLI) does not have the ability to query the AWS Price List API (which is really just a set of static files).

You could write a program to parse the JSON version of those files to extract the information you desire. Yes, there's a lot of entries in these files!

Tools such as JMESPath can assist in parsing JSON.

Update: As pointed out by sqlbot, the CSV version is actually friendly to use. For example, https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.csv has lines like:

  • TermType: OnDemand
  • PriceDescription: $0.269 per On Demand Linux m4.xlarge Instance Hour
  • Unit: Hrs
  • PricePerUnit: 0.269
  • Currency: USD
  • Product Family: Compute Instance
  • serviceCode: AmazonEC2
  • Location: Asia Pacific (Sydney)
  • Instance Type: m4.xlarge
  • Current Generation: Yes
  • Instance Family: General purpose
  • vCPU: 4
  • Physical Processor: Intel Xeon E5-2676 v3 (Haswell)
  • Clock Speed: 2.4 GHz
  • Memory: 16 GiB
  • Storage: EBS only
  • Network Performance: High
  • Processor Architecture: 64-bit
  • Tenancy: Shared
  • Operating System: Linux
  • License Model: No License required
  • usageType: APS2-BoxUsage:m4.xlarge
  • operation: RunInstances
  • Dedicated EBS Throughput: 750 Mbps
  • Enhanced Networking Supported: Yes
  • Processor Features: Intel AVX; Intel AVX2; Intel Turbo
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Thank you. Yes i already write a program to parse the JSON file but in the reserved section there are so much id like E5XVGVP8X39F46VD.MZU6U2429S.6YS6EN2CT7 can we find the meaning of these id or not? I will see the tools you just mentioned in order to make the treatement easier. – Imen Neji Apr 12 '17 at 23:55
  • Those strings are just IDs to uniquely identify the `rateCode` and can be ignored. The other fields will provide the information you seek, such as Instance Type, Operating System and price. – John Rotenstein Apr 13 '17 at 00:02
  • @ImenNeji I'd suggest downloading the CSV file, first. It's a denormalized representation of the information in the JSON structures. I think you'll find it's easier for humans to understand the meaning behind the data when you see it in the flat format provided by the CSV. – Michael - sqlbot Apr 13 '17 at 06:56
  • Yes I know these lines. But what's really too complicated is the terms part where we find the OnDemand and reserved instance. I tried many time to understand what's the meaning of the ID and also there is many instance like this { "rateCode" : "866ZGRHEVQD56AR2.JRTCKXETXF.6YS6EN2CT7", "description" : "$0.000 per Windows BYOL d2.8xlarge Dedicated Host Instance hour", "beginRange" : "0", "endRange" : "Inf", "unit" : "Hrs", "pricePerUnit" : { "USD" : "0.0000000000" }, – Imen Neji Apr 14 '17 at 19:05
  • You can consult the [AWS PriceList API documentation](http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/reading-an-offer.html). – John Rotenstein Apr 15 '17 at 10:24