Announcing the beta release of QMCLOUD pricing API

Blog Image
Mar 1, 2023
5,000 Views

Announcing the beta release of QMCLOUD pricing API

Background

Cloud cost management and optimization are tricky business. Effective cost optimization strategies should at a minimum include regular monitoring, reporting, and tracking cloud spend. The data from these activities can then be used to gain insights which then allows you to understand how to maximize the value and optimize costs.

One of the pain points in the current approach of cloud deployments is the inability to estimate the cost dynamically during deployment (before you deploy the resources). For example, if you are deploying a stack (i.e., a unit of infrastructure with multiple resources such as compute instances, load balancer, object storage) it’s difficult to estimate the cost for all the resources during the deployment before the resources are deployed. Most of the planning around cost is done during the architecture and design exercise or after the fact that resources were deployed.

The current solutions in the market that estimate cost during the deployment process include the ones below. Most of the other solutions either rely on offline calculators or determining cost after the fact that resources were deployed.

1. Terraform (with their paid version of cost policies in Team & Governance edition)

2. Pulumi – Cross guard policies with a sample code add on for cost control – At this time of the writing it only supports AWS and ec2

Introducing pricing API

We are thrilled to announce the beta availability of the QMCLOUD pricing API. The QMCLOUD pricing API provides cost estimates using one of the following methods:

a) QMCLOUD native

If you are using QMCLOUD to deploy cloud resources, the pricing API’s are integrated I the deployment process and will generate the per resource estimates on the fly

b) JSON file

This is like any online pricing calculator, but the main difference is the ability to submit the list of resources in a json format and programmatically using an API call. Both AWS and Azure too support this approach, but the QMCLOUD pricing API is multi cloud capable

c) State file

You can retrieve the state file (Pulumi or Terraform) and submit the state file programmatically (either inline or out of line from your tool/program) to call the pricing API.

Walkthrough

The following are the main steps to register and submit a file to retrieve the estimates:

Note – Usage of the API tool is subject to the privacy policy listed here.

https://qmcloud.io/privacy-policy

1)     Register user

Use the following URL to register to use the QMCLOUD Pricing API. Currently the registration is based on AWS Cognito as the identity provider. You will need to enter a username and an appropriate password.

Note – Coming soon – Other options for OIDC, and Social Network ID’s

https://pr.qmcloud.io/signup?client_id=49bi4d17pp1ust6aqrati72k69&response_type=code&scope= email+openid+phone&redirect_uri=https%3A%2F%2Fg9iqpn98fg.execute-api.us-east-1.amazonaws.com

You will receive an activation code to activate your account.

2)     Example using POST request in POSTMAN

Using postman, create a list of variables in an environment OR alternately use these variables in a POST request.

a)      Environment Variables

Name - cognito

cognitoClientId - 49bi4d17pp1ust6aqrati72k69

cognitoUserName - <replace with registered NAME>

cognitoUserPassword - <replace with PASSWORD>

cognitoAccessToken – <leave it as blank>

cognitoIdToken – <leave it as blank>

b)     Pre-Request script

Use the following sample pre-request script to generate the authtoken.

------------------PRE-REQUEST SCRIPT-----

var clientId = pm.environment.get("cognitoClientId");

var clientSecret =pm.environment.get("cognitoClientSecret");

var username =pm.environment.get("cognitoUserName");

var password =pm.environment.get("cognitoUserPassword");

pm.sendRequest({

         url:"https://cognito-idp.us-east-1.amazonaws.com/",

         method:'POST',

         header: {

                 'X-Amz-Target':  'AWSCognitoIdentityProviderService.InitiateAuth',

                 'Content-Type': 'application/x-amz-json-1.1'

                 },

          body: {

                mode: 'raw',

                raw: JSON.stringify({

                "AuthParameters": {

                "USERNAME": username,

                "PASSWORD": password

                 },

               "AuthFlow": "USER_PASSWORD_AUTH",

               "ClientId": clientId

}),

options: {

raw: {

language: 'json'

}

}

}

}, function (error, response) {

console.log(response.json());

pm.environment.set("cognitoIdToken",response.json().AuthenticationResult.IdToken);

});

-------END PRE-REQUEST-SCRIPT----

c)      Body (raw)

The POST body consists of various fields that include the resource name and filters. The minimum required key/value pairs are - "serviceCode" and at a minimum one filter. In addition the body structure.

The following is an example. The API uses many defaults if the filters.

--POSTMAN POST BODY RAW FORMAT----

{

 "productDetails": [

   {

     "filters": [

                   {

                     "field": "instanceType",

                     "value": "c5.24xlarge"

                   },

                   

                   {

                     "field": "location",

                     "value": "US East (N. Virginia)"

                   },

                   

                 

                   {

                       "field": "vcpu",

                       "value": "96"

                   },

                   

                   {        

                    "field": "networkPerformance",

                    "value": "25 Gigabit"

                   },

                   

               

                   {

                   

                   "field": "memory",

                   "value": "192 GiB"

                   },

                   {

                   "field": "tenancy",

                   "value": "Dedicated"

                   }

     ],

     "serviceCode": "AmazonEC2"

   },

   {

     "filters": [

                   {

                     "field": "instanceType",

                     "value": "c5.24xlarge"

                   },

                   

                   {

                     "field": "location",

                     "value": "US East (N. Virginia)"

                   },

                   

                 

                   {

                       "field": "vcpu",

                       "value": "96"

                   },

                   

                   {        

                    "field": "networkPerformance",

                    "value": "25 Gigabit"

                   },

                   

               

                   {

                   

                   "field": "memory",

                   "value": "192 GiB"

                   },

                   {

                   "field": "tenancy",

                   "value": "Dedicated"

                   }

     ],

     "serviceCode": "AmazonEC2"

   }

 ]

}

--END POSTMAN POST BODY RAW FORMAT----

d)     API endpoint

The following is the end point to post the json body to:

https://g9iqpn98fg.execute-api.us-east-1.amazonaws.com/fetch-pricing

e)     Sample output

The following is a sample output. Currently the API will list only on demand pricing by default unless a filter is overriding the type of pricing.

---SAMPLE PARTIAL PRICING API output---

{

   "pricings": [

       {

           "product": {

               "attributes": {

                   "abdInstanceClass": "c",

                   "availabilityzone": "NA",

                   "capacitystatus": "Used",

                   "classicnetworkingsupport": "false",

                   "clockSpeed": "3 GHz",

                   "currentGeneration": "Yes",

                   "dedicatedEbsThroughput": "14000 Mbps",

                   "ecu": "375",

                   "enhancedNetworkingSupported": "Yes",

                   "gpuMemory": "NA",

                   "instanceFamily": "Compute optimized",

                   "instanceType": "c5.24xlarge",

                   "intelAvx2Available": "Yes",

                   "intelAvxAvailable": "Yes",

                   "intelTurboAvailable": "Yes",

                   "licenseModel": "No License required",

                   "location": "US East (N. Virginia)",

                   "locationType": "AWS Region",

                   "marketoption": "OnDemand",

                   "memory": "192 GiB",

                   "networkPerformance": "25 Gigabit",

                   "normalizationSizeFactor": "192",

                   "operatingSystem": "Linux",

                   "operation": "RunInstances",

                   "physicalProcessor": "Intel Xeon Platinum 8275L",

                   "preInstalledSw": "NA",

                   "processorArchitecture": "64-bit",

                   "processorFeatures": "Intel AVX; Intel AVX2; Intel AVX512; Intel Deep Learning Boost; Intel Turbo",

                   "regionCode": "us-east-1",

                   "servicecode": "AmazonEC2",

                   "servicename": "Amazon Elastic Compute Cloud",

                   "storage": "EBS only",

                   "tenancy": "Dedicated",

                   "usagetype": "DedicatedUsage:c5.24xlarge",

                   "vcpu": "96",

                   "vpcnetworkingsupport": "true"

               },

               "productFamily": "Compute Instance",

               "sku": "K9259S24TX784EZS"

           },

           "publicationDate": "2023-02-28T20:26:12Z",

           "serviceCode": "AmazonEC2",

           "terms": {

               "OnDemand": {

                   "K9259S24TX784EZS.JRTCKXETXF": {

                       "effectiveDate": "2023-02-01T00:00:00Z",

                       "offerTermCode": "JRTCKXETXF",

                       "priceDimensions": {

                           "K9259S24TX784EZS.JRTCKXETXF.6YS6EN2CT7": {

                               "appliesTo": [],

                               "beginRange": "0",

                               "description": "$4.325 per Dedicated Linux c5.24xlarge Instance Hour",

                               "endRange": "Inf",

                               "pricePerUnit": {

                                   "USD": "4.3250000000"

                               },

                               "rateCode": "K9259S24TX784EZS.JRTCKXETXF.6YS6EN2CT7",

                               "unit": "Hrs"

                           }

                       },

                       "sku": "K9259S24TX784EZS",

                       "termAttributes": {}

                   }

-----END SAMPLE PRICING OUTPUT---

Get Started

Get started with the POSTMAN public workspace.

https://www.postman.com/qclouddev/workspace/qmcloud-pricing-api-beta

Caveats:

Current support is limited to AWS and specifically AmazonEc2 instance only.

We plan to release additional resource support and Azure support in the next quarter.

Summary

The QMCLOUD pricing API is another step towards adding and supporting critical features for cloud infrastructure deployments. Such features around security and cost control policies will strengthen the governance aspects of cloud deployments and allows users to accurately define the guardrails and desired posture/state.

We plan to release these features in the coming months. In the meantime, contact us for any questions and specifically for enrolling in our early adopter's program and understand the incentives.