AWS Price List API Serivces, Attributes, and Attribute Values
This is a dump of the services, attributes, and attribute values available from the AWS Price List API's DescribeServices and GetAttributeValues functions. Pulling those are the first two steps in order to get data from the GetProducts function where the actual pricing details reside.
I'm posting this becuase it's silly for everyone to spend time doing the same thing. (I'm also including a usage example below that shows how to use how to use the data)
Update Frequency
This page was generated on Sept. 29, 2022. If you need a more recent set of the data you can pull the scripts from the repo.
The Data
Usage
This example shows how to use the data to start getting details on EC2 instances. (Getting the actual prices for is a little complicated. I'm working on post with the specifics for that)
#!/usr/bin/env python3
import boto3
import json
client = boto3.client('pricing')
paginator = client.get_paginator('get_products')
response_iterator = paginator.paginate(
ServiceCode='AmazonEC2',
Filters=[
{
'Type': 'TERM_MATCH',
'Field': 'regionCode',
'Value': 'us-east-1'
},
{
'Type': 'TERM_MATCH',
'Field': 'operatingSystem',
'Value': 'Linux'
}
],
FormatVersion='aws_v1',
PaginationConfig={
'MaxItems': 5,
},
)
for page in response_iterator:
for price_data_string in page['PriceList']:
price_data = json.loads(price_data_string)
print(price_data['product']['attributes']['instanceType'])
Notes
-
Values for
ServiceCode
in the example come from the first level of the data. -
Values for
Field
in the example come from the second level of the data. -
Values for
Value
in the example come from the third level of the data. - This example uses the paginator that AWS provides. I wish more APIs that required pagination included this with their SDKs. You can see details on the python code here (I didn't find the top level docs)
- I limited the data pulls to 1000 items. EC2 has way more skus than that. Filtering that will depend on your end goal
References
- Price List API Home Page - nothing really here except links to the functions below.
- Price List API DescribeServices Documentation - shows the basic structure with links to docs for specific languages
- Price List API GetAttributeValues Documentation - top level docs with links to specific language docs
- Price List API GetProducts Documentation - top level docs with links to specific language docs. This is the end goal. You use the above data to make calls to this API to get produce pricing info