[Python] AWS Pricing API returns no data for Amazon RDS 'gp3' and 'io2' volume types using...

Discussão em 'Python' iniciado por Stack, Julho 22, 2025.

  1. Stack

    Stack Membro Participativo

    I've successfully retrieved pricing data for the instance type "db.m6i.2xlarge" in Amazon RDS using AWS Pricing API (boto3). However, when I attempted to fetch pricing data for the RDS volumes types "gp3" and "io2" using a similar approach, I consistently get an empty response (PriceList is empty).

    Here's the code I used successfully for fetching instance costs (db.m6i.2xlarge):

    def get_instance_cost_rds(region_name, instance_name, boto3_client):
    try:
    response = boto3_client.get_products(
    ServiceCode="AmazonRDS",
    Filters=[
    {"Type": "TERM_MATCH", "Field": "instanceType", "Value": instance_name},
    {"Type": "TERM_MATCH", "Field": "location", "Value": region_name},
    {"Type": "TERM_MATCH", "Field": "databaseEngine", "Value": "PostgreSQL"}
    ],
    )
    if response["PriceList"]:
    return response["PriceList"]
    except Exception as ex:
    logging.exception("Error fetching instance cost: %s", ex)


    And here's how I've tried retrieving "gp3" and "io2" RDS volume prices (but failed - returns empty PriceList):

    def get_volume_cost_rds(region_name, volume_type, boto3_client):
    try:
    response = boto3_client.get_products(
    ServiceCode="AmazonRDS",
    Filters=[
    {"Type": "TERM_MATCH", "Field": "volumeType", "Value": volume_type},
    {"Type": "TERM_MATCH", "Field": "location", "Value": region_name},
    ],
    )
    if response["PriceList"]:
    return response["PriceList"]
    else:
    print("No data found in PriceList for", volume_type)
    except Exception as ex:
    logging.exception("Error fetching volume cost: %s", ex)

    # Calling like this:
    region_name = "US East (N. Virginia)"
    boto3_client = boto3.client('pricing', region_name='us-east-1')

    gp3_prices = get_volume_cost_rds(region_name, "gp3", boto3_client)
    io2_prices = get_volume_cost_rds(region_name, "io2", boto3_client)


    Why does the AWS Pricing API return an empty PriceList for RDS gp3 or io2 volume types? Is there a special way to fetch RDS volume pricing using the AWS Pricing API?

    Any help would be highly appreciated. Thanks!

    Continue reading...

Compartilhe esta Página