Paul Draper
Paul Draper

Reputation: 83205

Querying the cost of launching a instance from the AWS Pricing API

I am using the AWS Pricing API:

http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html

The issue is that it has data like

"KV46EU5KJGKB53ZX" : {
  "sku" : "KV46EU5KJGKB53ZX",
  "productFamily" : "Compute Instance",
  "attributes" : {
    "servicecode" : "AmazonEC2",
    "location" : "US East (N. Virginia)",
    "locationType" : "AWS Region",

I don't know how to correlate locationType and location with the data I use to launch EC2 instances (e.g. in us-east-1).

Is there a way to know the cost of launching an EC2 instance?

Upvotes: 2

Views: 910

Answers (4)

David
David

Reputation: 337

Just use the regionCode instead of location

Upvotes: 0

Vincent J
Vincent J

Reputation: 5778

Just built it myself. I know it will not be updated but...

NB: China is missing from this list I extracted from AWS pricing user interface

{
    "AWS GovCloud (US-East)": "us-gov-east-1",
    "AWS GovCloud (US-West)": "us-gov-west-1",
    "Africa (Cape Town)": "af-south-1",
    "Asia Pacific (Hong Kong)": "ap-east-1",
    "Asia Pacific (Mumbai)": "ap-south-1",
    "Asia Pacific (Osaka-Local)": "ap-northeast-3",
    "Asia Pacific (Seoul)": "ap-northeast-2",
    "Asia Pacific (Singapore)": "ap-southeast-1",
    "Asia Pacific (Sydney)": "ap-southeast-2",
    "Asia Pacific (Tokyo)": "ap-northeast-1",
    "Canada (Central)": "ca-central-1",
    "EU (Frankfurt)": "eu-central-1",
    "EU (Ireland)": "eu-west-1",
    "EU (London)": "eu-west-2",
    "EU (Milan)": "eu-south-1",
    "EU (Paris)": "eu-west-3",
    "EU (Stockholm)": "eu-north-1",
    "Middle East (Bahrain)": "me-south-1",
    "South America (Sao Paulo)": "sa-east-1",
    "US East (Boston)": "us-east-1-bos-1",
    "US East (Houston)": "us-east-1-iah-1",
    "US East (Miami)": "us-east-1-mia-1",
    "US East (N. Virginia)": "us-east-1",
    "US East (Ohio)": "us-east-2",
    "US East (Verizon) - Atlanta": "us-east-1-wl1-atl1",
    "US East (Verizon) - Boston": "us-east-1-wl1",
    "US East (Verizon) - Dallas": "us-east-1-wl1-dfw1",
    "US East (Verizon) - Miami": "us-east-1-wl1-mia1",
    "US East (Verizon) - New York": "us-east-1-wl1-nyc1",
    "US East (Verizon) - Washington DC": "us-east-1-wl1-was1",
    "US West (Los Angeles)": "us-west-2-lax-1",
    "US West (N. California)": "us-west-1",
    "US West (Oregon)": "us-west-2",
    "US West (Verizon) - Las Vegas": "us-west-2-wl1-las1",
    "US West (Verizon) - San Francisco Bay Area": "us-west-2-wl1",
}

Upvotes: 1

at0mzk
at0mzk

Reputation: 1942

I recommend jq to work with large json documents. For OnDemand pricing of sku KV46EU5KJGKB53ZX for example:

curl -s https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json \
 | jq .terms.OnDemand.KV46EU5KJGKB53ZX

gives

{
  "KV46EU5KJGKB53ZX.JRTCKXETXF": {
    "offerTermCode": "JRTCKXETXF",
    "sku": "KV46EU5KJGKB53ZX",
    "effectiveDate": "2016-12-01T00:00:00Z",
    "priceDimensions": {
      "KV46EU5KJGKB53ZX.JRTCKXETXF.6YS6EN2CT7": {
        "rateCode": "KV46EU5KJGKB53ZX.JRTCKXETXF.6YS6EN2CT7",
        "description": "$0.156 per Dedicated RHEL m1.medium Instance Hour",
        "beginRange": "0",
        "endRange": "Inf",
        "unit": "Hrs",
        "pricePerUnit": {
          "USD": "0.1560000000"
        },
        "appliesTo": []
      }
    },
    "termAttributes": {}
  }
}

Upvotes: 1

Michael - sqlbot
Michael - sqlbot

Reputation: 178956

I am not aware of the presence of this cross-reference/mapping data within the structures provided by the price list API, and it is unfortunately not provided by DescribeRegions in the EC2 API, either.

It is, however, readily available on the Regions and Endpoints page under general documentation. From that info, you can build a simple dictionary or lookup table.

Upvotes: 1

Related Questions