Aws-sdk-js: AWS.Pricing - getProducts method results in InvalidParameterException

Created on 28 Jun 2020  路  2Comments  路  Source: aws/aws-sdk-js

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
Based on the documentation of the getProducts method of the AWS Price List Service API (https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Pricing.html#getProducts-property) the example shown there is not working. The error InvalidParameterException is thrown:
InvalidParameterException: Input Parameters are invalid. serviceCode cannot be null or empty

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
Node.js v10.19.0

SDK version number
v2.705.0

To Reproduce (observed behavior)
Try out the example code in the documentation:

 var params = {
  Filters: [
     {
    Field: "ServiceCode", 
    Type: "TERM_MATCH", 
    Value: "AmazonEC2"
   }, 
     {
    Field: "volumeType", 
    Type: "TERM_MATCH", 
    Value: "Provisioned IOPS"
   }
  ], 
  FormatVersion: "aws_v1", 
  MaxResults: 1
 };
 pricing.getProducts(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
 });

Expected behavior
Retrieve the data about the service as shown in the documentation:

data = {
    FormatVersion: "aws_v1", 
    NextToken: "57r3EXAMPLEujbzWfHF7Ciw==:ywSmZsD3mtpQmQLQ5XfOsIMkYybSj+vAT+kGmwMFq+K9DGmIoJkz7lunVeamiOPgthdWSO2a7YKojCO+zY4dJmuNl2QvbNhXs+AJ2Ufn7xGmJncNI2TsEuAsVCUfTAvAQNcwwamtk6XuZ4YdNnooV62FjkV3ZAn40d9+wAxV7+FImvhUHi/+f8afgZdGh2zPUlH8jlV9uUtj0oHp8+DhPUuHXh+WBII1E/aoKpPSm3c=", 
    PriceList: [
       "{\"product\":{\"productFamily\":\"Storage\",\"attributes\":{\"storageMedia\":\"SSD-backed\",\"maxThroughputvolume\":\"320 MB/sec\",\"volumeType\":\"Provisioned IOPS\",\"maxIopsvolume\":\"20000\",\"servicecode\":\"AmazonEC2\",\"usagetype\":\"CAN1-EBS:VolumeUsage.piops\",\"locationType\":\"AWS Region\",\"location\":\"Canada (Central)\",\"servicename\":\"Amazon Elastic Compute Cloud\",\"maxVolumeSize\":\"16 TiB\",\"operation\":\"\"},\"sku\":\"WQGC34PB2AWS8R4U\"},\"serviceCode\":\"AmazonEC2\",\"terms\":{\"OnDemand\":{\"WQGC34PB2AWS8R4U.JRTCKXETXF\":{\"priceDimensions\":{\"WQGC34PB2AWS8R4U.JRTCKXETXF.6YS6EN2CT7\":{\"unit\":\"GB-Mo\",\"endRange\":\"Inf\",\"description\":\"$0.138 per GB-month of Provisioned IOPS SSD (io1)  provisioned storage - Canada (Central)\",\"appliesTo\":[],\"rateCode\":\"WQGC34PB2AWS8R4U.JRTCKXETXF.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.1380000000\"}}},\"sku\":\"WQGC34PB2AWS8R4U\",\"effectiveDate\":\"2017-08-01T00:00:00Z\",\"offerTermCode\":\"JRTCKXETXF\",\"termAttributes\":{}}}},\"version\":\"20170901182201\",\"publicationDate\":\"2017-09-01T18:22:01Z\"}"
    ]
   }
bug documentation

All 2 comments

Hey @dn0912 thank-you for reaching out to us with your issue.

The seviceCode is required as mentioned here.

However, I understand the frustration the API reference not being concise, reached out to the service team to work on a fix.

Hi @ajredniwja
Thank you for clarification!

Was this page helpful?
0 / 5 - 0 ratings