in ddbtools/pricing.py [0:0]
def get_storage_class_pricing(self, region_code: str, volume_type: str) -> Decimal:
"""Get table class pricing by looking for a specific volume type in the specified region."""
response = self.pricing_client.get_products(
ServiceCode=constants.DDB_RESOURCE_CODE,
Filters=[{'Type': 'TERM_MATCH',
'Field': 'volumeType',
'Value': volume_type},
{'Type': 'TERM_MATCH',
'Field': 'regionCode',
'Value': region_code}
],
FormatVersion='aws_v1',
MaxResults=1
)
price_list = response['PriceList']
product = json.loads(price_list[0])
offer = product['terms']['OnDemand'].popitem()
offer_terms = offer[1]
price_dimensions = offer_terms['priceDimensions']
for price_dimension_code in price_dimensions:
price_terms = price_dimensions[price_dimension_code]
price_per_unit = price_terms['pricePerUnit']['USD']
storage_pricing = Decimal(price_per_unit)
# Regions with free tier pricing will have an initial entry set to zero; skip this
if storage_pricing != 0:
return storage_pricing
return None