turbot / steampipe-plugin-aws

Use SQL to instantly query AWS resources across regions and accounts. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/aws
Apache License 2.0
189 stars 104 forks source link

OfferingClass not present aws_pricing_product attributes for service_code AmazonEC2 #1862

Closed rasta-rocket closed 1 year ago

rasta-rocket commented 1 year ago

Describe the bug

When selecting rows from the table aws_pricing_product for the service_code AmazonEC2 the field OfferingClass is not present in the attributes

Steampipe version (steampipe -v) v0.20.9

Plugin version (steampipe plugin list) v0.113.0

To reproduce

select
attributes ->> 'tenancy' as tenancy,
attributes ->> 'regionCode' as region,
attributes ->> 'offeringClass' as offeringclass,
term, unit,
price_per_unit,
purchase_option,
lease_contract_length
from aws_pricing_product where service_code='AmazonEC2' and filters='{"regionCode": "eu-west-1", "tenancy": "Shared", "operatingSystem":"Linux", "operation":"RunInstances", "instanceType": "m5.large"}' :: jsonb and term = 'Reserved'

Results

+---------+-----------+---------------+----------+----------+----------------+-----------------+-----------------------+
| tenancy | region    | offeringclass | term     | unit     | price_per_unit | purchase_option | lease_contract_length |
+---------+-----------+---------------+----------+----------+----------------+-----------------+-----------------------+
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0320000000   | Partial Upfront | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 1057           | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0460000000   | No Upfront      | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0610000000   | No Upfront      | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 743            | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0280000000   | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0860000000   | No Upfront      | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0210000000   | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 1457           | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 562            | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0670000000   | No Upfront      | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 281            | Partial Upfront | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Hrs      | 0.0410000000   | Partial Upfront | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 551            | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 706            | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | <null>        | Reserved | Quantity | 360            | Partial Upfront | 1yr                   |
+---------+-----------+---------------+----------+----------+----------------+-----------------+-----------------------+

Expected behavior

+---------+-----------+---------------+----------+----------+----------------+-----------------+-----------------------+
| tenancy | region    | offeringclass    | term     | unit     | price_per_unit | purchase_option | lease_contract_length |
+---------+-----------+---------------+----------+----------+----------------+-----------------+-----------------------+
| Shared  | eu-west-1 | standard        | Reserved | Hrs      | 0.0320000000   | Partial Upfront | 1yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Quantity | 1057           | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | standard       | Reserved | Hrs      | 0.0460000000   | No Upfront      | 3yr                   |
| Shared  | eu-west-1 | standard       | Reserved | Hrs      | 0.0000000000   | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Hrs      | 0.0610000000   | No Upfront      | 3yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Quantity | 743            | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Hrs      | 0.0280000000   | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Hrs      | 0.0860000000   | No Upfront      | 1yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Hrs      | 0.0210000000   | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | convertible        | Reserved | Quantity | 1457           | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Hrs      | 0.0000000000   | All Upfront     | 3yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Quantity | 562            | Partial Upfront | 3yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Hrs      | 0.0670000000   | No Upfront      | 1yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Quantity | 281            | Partial Upfront | 1yr                   |
| Shared  | eu-west-1 | standard      | Reserved | Hrs      | 0.0410000000   | Partial Upfront | 1yr                   |
| Shared  | eu-west-1 | standard        | Reserved | Quantity | 551            | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | convertible       | Reserved | Quantity | 706            | All Upfront     | 1yr                   |
| Shared  | eu-west-1 | standard       | Reserved | Quantity | 360            | Partial Upfront | 1yr                   |
+---------+-----------+---------------+----------+----------+----------------+-----------------+-----------------------+

Additional context

Don't hesitate to reach me for any questions 😉 Cheers ☀️

rajlearner17 commented 1 year ago

@rasta-rocket Thanks for using Steampipe! Welcome 🤝

Sad to see you got bumped here. I see the same. We will investigate this and get back to you!

rajlearner17 commented 1 year ago

@ rasta-rocket, Thanks for waiting; we did some analysis, but this may need more insight & debugging.

The below list does not have any property under the attribute of offeringClass , from where you got the reference that API will return this property? The AWS document , also does not show up this property. We might be missing to see some reference of it in any API doc, pls let us know if you have any reference in any place indicating this must be part of the API response.

This GO API is used.

> select jsonb_pretty(attributes) from aws_pricing_product where service_code='AmazonEC2' limit 1
+------------------------------------------------------------------------------+
| jsonb_pretty                                                                 |
+------------------------------------------------------------------------------+
| {                                                                            |
|     "ecu": "NA",                                                             |
|     "vcpu": "2",                                                             |
|     "memory": "4 GiB",                                                       |
|     "storage": "EBS only",                                                   |
|     "tenancy": "Dedicated",                                                  |
|     "location": "Asia Pacific (Tokyo)",                                      |
|     "gpuMemory": "NA",                                                       |
|     "operation": "RunInstances:0202",                                        |
|     "usagetype": "APN1-DedicatedUsage:c6i.large",                            |
|     "clockSpeed": "3.5 GHz",                                                 |
|     "regionCode": "ap-northeast-1",                                          |
|     "servicecode": "AmazonEC2",                                              |
|     "servicename": "Amazon Elastic Compute Cloud",                           |
|     "instanceType": "c6i.large",                                             |
|     "licenseModel": "No License required",                                   |
|     "locationType": "AWS Region",                                            |
|     "marketoption": "OnDemand",                                              |
|     "capacitystatus": "Used",                                                |
|     "instanceFamily": "Compute optimized",                                   |
|     "preInstalledSw": "SQL Web",                                             |
|     "operatingSystem": "Windows",                                            |
|     "availabilityzone": "NA",                                                |
|     "currentGeneration": "Yes",                                              |
|     "intelAvxAvailable": "Yes",                                              |
|     "physicalProcessor": "Intel Xeon 8375C (Ice Lake)",                      |
|     "processorFeatures": "Intel AVX; Intel AVX2; Intel AVX512; Intel Turbo", |
|     "intelAvx2Available": "Yes",                                             |
|     "networkPerformance": "Up to 12500 Megabit",                             |
|     "intelTurboAvailable": "Yes",                                            |
|     "vpcnetworkingsupport": "true",                                          |
|     "processorArchitecture": "64-bit",                                       |
|     "dedicatedEbsThroughput": "Up to 10000 Mbps",                            |
|     "normalizationSizeFactor": "4",                                          |
|     "classicnetworkingsupport": "false",                                     |
|     "enhancedNetworkingSupported": "Yes"                                     |
| }                                                                            |
+------------------------------------------------------------------------------+
> 

This is the PR, which contributed to this table. We will still investigate.

CC @cbruno10 @ParthaI

rasta-rocket commented 1 year ago

@rajlearner17 Thanks for your reactivity 🚀 I get the attribute from the table aws_pricing_service_attribute Where I did

select * from aws_pricing_service_attribute where service_code='AmazonEC2'
+--------------+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
| service_code | attribute_name              | attribute_values                                                                                                                                                                        >
+--------------+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
| AmazonEC2    | memory                      | ["0.5 GiB","0.613 GiB","1 GiB","1.7 GiB","10.5 GiB","1024 GiB","1152 GiB","117 GiB","12 GiB","122 GiB","12288 GiB","128 GiB","144 GiB","15 GiB","15.25 GiB","1536 GiB","16 GiB","160 GiB>
| AmazonEC2    | vcpu                        | ["128","12","16","192","1","224","24","2","32","36","40","448","48","4","64","72","8","96"]                                                                                             >
| AmazonEC2    | instanceCapacity9xlarge     | ["2"]                                                                                                                                                                                   >
| AmazonEC2    | provisioned                 | ["No","Yes"]                                                                                                                                                                            >
| AmazonEC2    | intelTurboAvailable         | ["No","Yes"]                                                                                                                                                                            >
| AmazonEC2    | toLocation                  | ["AWS GovCloud (US-West)","Asia Pacific (Seoul)","Asia Pacific (Singapore)","Asia Pacific (Sydney)","Asia Pacific (Tokyo)","EU (Frankfurt)","EU (Ireland)","External","South America (Sa>
| AmazonEC2    | instanceCapacityMedium      | ["16","32","64"]                                                                                                                                                                        >
| AmazonEC2    | transferType                | ["AWS Inbound","AWS Outbound","InterRegion Inbound","InterRegion Outbound","IntraRegion"]                                                                                               >
| AmazonEC2    | fromRegionCode              | ["ap-northeast-1","ap-northeast-2","ap-southeast-1","ap-southeast-2","eu-central-1","eu-west-1","sa-east-1","us-east-1","us-gov-west-1","us-west-1","us-west-2"]                        >
...                                                                                                                                                               >
| AmazonEC2    | volumeApiName               | ["gp2","gp3","io1","io2","sc1","st1","standard"]                                                                                                                                        >
| AmazonEC2    | physicalProcessor           | ["AMD EPYC 7571","AMD EPYC 7R13 Processor","AMD EPYC 7R32","AWS Graviton Processor","AWS Graviton2 Processor","AWS Graviton3 Processor","Apple M1 chip with 8-core CPU, 8-core GPU, and >
|              |                             | ke)","Intel Xeon Scalable (Skylake)","Variable"]                                                                                                                                        >
| AmazonEC2    | marketoption                | ["OnDemand"]                                                                                                                                                                            >
| AmazonEC2    | OfferingClass               | ["convertible","standard"]                                                                                                                                                              >
| AmazonEC2    | volumeType                  | ["Cold HDD","General Purpose","Magnetic","Provisioned IOPS","Throughput Optimized HDD"]                                                                                                 >
| AmazonEC2    | instanceCapacity32xlarge    | ["1"]                                                                                                                                                                                   >

And after checking directly on the AWS API indeed it is present

AWS_DEFAULT_REGION=us-east-1  aws --endpoint-url "https://api.pricing.us-east-1.amazonaws.com" pricing describe-services --service "AmazonEC2"
FormatVersion: aws_v1
Services:
- AttributeNames:
  - instanceCapacityMetal
  - volumeType
  - maxIopsvolume
  - instance
  - classicnetworkingsupport
  - instanceCapacity10xlarge
  - fromRegionCode
  - locationType
  - toLocationType
  - instanceFamily
  - operatingSystem
  - toRegionCode
  - clockSpeed
  - LeaseContractLength
  - ecu
  - networkPerformance
  - instanceCapacity8xlarge
  - group
  - gpuMemory
  - maxThroughputvolume
  - ebsOptimized
  - vpcnetworkingsupport
  - maxVolumeSize
  - gpu
  - intelAvxAvailable
  - processorFeatures
  - instanceCapacity4xlarge
  - servicecode
  - groupDescription
  - elasticGraphicsType
  - volumeApiName
  - processorArchitecture
  - physicalCores
  - fromLocation
  - snapshotarchivefeetype
  - marketoption
  - availabilityzone
  - productFamily
  - fromLocationType
  - enhancedNetworkingSupported
  - intelTurboAvailable
  - memory
  - dedicatedEbsThroughput
  - vcpu
  - OfferingClass <----------------------
  - instanceCapacityLarge
  - capacitystatus
  - termType
  - storage
  - toLocation
  - intelAvx2Available
  - storageMedia
  - regionCode
  - physicalProcessor
  - provisioned
  - servicename
  - PurchaseOption
  - instancesku
  - productType
  - instanceCapacity18xlarge
  - instanceType
  - tenancy
  - usagetype
  - normalizationSizeFactor
  - instanceCapacity16xlarge
  - instanceCapacity2xlarge
  - maxIopsBurstPerformance
  - instanceCapacity12xlarge
  - instanceCapacity32xlarge
  - instanceCapacityXlarge
  - licenseModel
  - currentGeneration
  - preInstalledSw
  - transferType
  - location
  - instanceCapacity24xlarge
  - instanceCapacity9xlarge
  - instanceCapacityMedium
  - operation
  - resourceType
  ServiceCode: AmazonEC2
rajlearner17 commented 1 year ago

@rasta-rocket, We will dig into it further. Thanks!

rasta-rocket commented 1 year ago

@rajlearner17 I might find why ... tell me WDYT about it 😉 ⬆️

rajlearner17 commented 1 year ago

@rasta-rocket, I think you nailed it 😄, tbh, I was slowly routing myself in the same direction. Good to see this PR.

CC @ParthaI to check this further and take it forward for release.

rajlearner17 commented 1 year ago

@rasta-rocket Wondering Is there any such property (apart from offeringclass) we need to have based on your working experience?

rasta-rocket commented 1 year ago

@rajlearner17 Looking at the termAttributes field there are only 3 subkeys (OfferingClass,PurchaseOption,LeaseContractLength) which are (soon) already there, so I would say no 😅 Thx for asking 🙏