https://infracost.io logo
#general
Title
# general
f

flaky-architect-33900

08/27/2021, 6:02 AM
Hi ,I Hope you all are doing great , I am new to open source and this infracost . I had started exploring this infracost and i want to use cloud pricing api . I have few doubts regrading cloud pricing api response of infracost , for some attributes of azure it's giving multiple prices , i figured out in one is for windows and other is for linux  . I verified it from azure pricing cal "prices": [                     {                         "USD": "40.582"                     },                     {                         "USD": "34.694"                     }                 ]  but for this response i am confused  "prices": [                     {                         "USD": "37676"                     },                     {                         "USD": "3.584"                     },                     {                         "USD": "18838"                     }                 ]  because middle is for linux machine of Das v4 series of instance D64as v4 but the first and third in array is confusing .Can some one throw some light in this
b

bulky-florist-87783

08/27/2021, 6:22 AM
seems like you are using the graphql interface to get the price, the prices array consist of multiple resource based pricing, like one can be storage cost, other vm cost etc
can you share the query you are trying or terraform file ?
f

flaky-architect-33900

08/27/2021, 6:30 AM
Copy code
{
  "query": "{ products(filter: {vendorName: \"azure\",region: \"westus\", service: \"Virtual Machines\", attributeFilters: [{key :\"armSkuName\" , value : \"Standard_M128m\"}]}) { attributes { key, value } prices  { USD } } } "
}
b

bulky-florist-87783

08/27/2021, 6:35 AM
Copy code
these seems to 3 different compute sizes
your query is matching three computes sizes
M128m Spot
M128m Low Priority
M128m (Standard)
you can change your query to look for specific skuName or preferably meterName
armSkuName are same for all three
👍 2
f

flaky-architect-33900

08/27/2021, 7:43 AM
I tried this query {"query": "{ products(filter: {vendorName: \"azure\",region: \"westus\", service: \"Virtual Machines\", attributeFilters: [{key :\"skuName\" , value : \"M128m\"}]}) { attributes { key, value } prices { USD } } } " } and got { "data": { "products": [ { "attributes": [ { "key": "meterId", "value": "871771b5-dd37-59ed-aa19-b367d7db8823" }, { "key": "skuName", "value": "M128m" }, { "key": "meterName", "value": "M128m" }, { "key": "productId", "value": "DZH318Z0BQ4W" }, { "key": "serviceId", "value": "DZH313Z7MMC8" }, { "key": "armSkuName", "value": "Standard_M128m" }, { "key": "productName", "value": "Virtual Machines MS Series" }, { "key": "serviceFamily", "value": "Compute" }, { "key": "effectiveStartDate", "value": "2020-07-01T000000Z" } ], "prices": [ { "USD": "255081" }, { "USD": "34.694" }, { "USD": "174777" } ] }, { "attributes": [ { "key": "meterId", "value": "074ab99b-0be2-53d4-9aa1-5b6c6678537f" }, { "key": "skuName", "value": "M128m" }, { "key": "meterName", "value": "M128m" }, { "key": "productId", "value": "DZH318Z0BPW5" }, { "key": "serviceId", "value": "DZH313Z7MMC8" }, { "key": "armSkuName", "value": "Standard_M128m" }, { "key": "productName", "value": "Virtual Machines MS Series Windows" }, { "key": "serviceFamily", "value": "Compute" }, { "key": "effectiveStartDate", "value": "2021-02-01T000000Z" } ], "prices": [ { "USD": "40.582" }, { "USD": "34.694" } ] } ] } } I got products this time second one is fine , but first one is still confusing ,as it have array of 3 values [ 255081 , 34.694 , 174777 ] . Iam sure about the middle price is of linux , but the first and third one is confusing , what this first and third price represents ?
b

bulky-florist-87783

08/27/2021, 8:31 AM
Copy code
# Write your query or mutation here
query {
  products(
    filter: {
      vendorName: "azure",
      service: "Virtual Machines",
      region: "westus",
 				attributeFilters: [
          {key: "meterName", value: "M128m"},
          {key: "armSkuName", value: "Standard_M128m"},

      ]
    },
  ) {
    prices(
      filter: {
				purchaseOption: "Consumption",
      },
    ) { USD,
      purchaseOption
      startUsageAmount
    unit}
  }
}
try this one
here price is associated with Reservation of 1 and 3 years (255081, 174777), i guess you are looking for consumption so u can try above query
🙌 1
Copy code
{
  "data": {
    "products": [
      {
        "prices": [
          {
            "USD": "34.694",
            "purchaseOption": "Consumption",
            "startUsageAmount": "0",
            "unit": "1 Hour"
          }
        ]
      },
      {
        "prices": [
          {
            "USD": "40.582",
            "purchaseOption": "Consumption",
            "startUsageAmount": "0",
            "unit": "1 Hour"
          }
        ]
      }
    ]
  }
}
👍 2
5 Views