Skip to content

Boto3 get_savings_plans_utilization_details DIMENSION as INSTANCE_TYPE?

0

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ce/client/get_savings_plans_utilization_details.html

Hi, The document above says that INSTANCE_TYPE is a valid value for DIMENSION field in the Request Syntax. However, when I call this API, i get the following error:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the GetSavingsPlansUtilizationDetails operation: Dimension INSTANCE_TYPE is not allowed. Allowed dimension(s): LINKED_ACCOUNT, SAVINGS_PLAN_ARN, SAVINGS_PLANS_TYPE, REGION, PAYMENT_OPTION, INSTANCE_TYPE_FAMILY, AGREEMENT_END_DATE_TIME_AFTER, AGREEMENT_END_DATE_TIME_BEFORE

I am using boto3 version boto3-1.34.107

Is there a way to get savings plan utilization details by each INSTANCE_TYPE within each region instead of INSTANCE_TYPE_FAMILY?

Thanks in advance.

  • Can you post the call you are making?

  • Hi iBehr, Here's the call I am making in Python and the error is given below: response = ce.get_savings_plans_utilization_details( TimePeriod={ 'Start': '2024-05-01', 'End': '2024-05-17' }, Filter = { 'And': [ { 'Dimensions': { 'Key': 'INSTANCE_TYPE', 'Values': ['m6g.medium'] } }, { 'Dimensions': { 'Key': 'REGION', 'Values': ['ap-south-2'] } } ] }, DataType=['UTILIZATION'] )

    An error occurred (ValidationException) when calling the GetSavingsPlansUtilizationDetails operation: Dimension INSTANCE_TYPE is not allowed. Allowed dimension(s): INSTANCE_TYPE_FAMILY, (...)

  • Looks like the documentation's Request Syntax is misleading for several methods. Most of the options listed in the documentation for 'DIMENSION' are not actually permitted. Ran into a few more instances today: e.g.

    botocore.exceptions.ClientError: Unsupported [Dimension Key=SAVINGS_PLAN_ARN], dimension key must be a subset of SERVICE,REGION,INSTANCE_TYPE_FAMILY

    https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ce/client/get_savings_plans_coverage.html This page lists a lot more options for dimension key.

1 Answer
0

Hi tranquilv,

You're correct — this is a known documentation discrepancy. The boto3/AWS SDK docs list INSTANCE_TYPE as a valid dimension in the generic Expression object shared across many Cost Explorer APIs, but GetSavingsPlansUtilizationDetails only supports a subset of dimensions for filtering.

Confirmed Supported Dimensions

Per the AWS SDK for Ruby V3 docs (which are more precise than the boto3 auto-generated docs), GetSavingsPlansUtilizationDetails supports only these filter dimensions:

  • LINKED_ACCOUNT
  • SAVINGS_PLAN_ARN
  • INSTANCE_TYPE_FAMILY

The error message you received confirms this. The INSTANCE_TYPE (e.g., m6g.medium) granularity is not available through this API.

Why the Documentation Is Misleading

The Cost Explorer APIs share a common Expression object definition that includes ALL possible dimension keys (INSTANCE_TYPE, SERVICE, REGION, etc.). However, each specific API endpoint only accepts a subset. The auto-generated SDK documentation (including boto3) shows the full Expression schema without clearly indicating which dimensions each individual API actually supports. You can discover the actual allowed dimensions at runtime using:

response = ce.get_dimension_values(
    TimePeriod={'Start': '2024-05-01', 'End': '2024-05-17'},
    Dimension='SAVINGS_PLANS_TYPE',  # or other valid dimensions
    Context='SAVINGS_PLANS'
)

Workaround: Getting SP Utilization by Instance Type

Since the Savings Plans APIs don't support INSTANCE_TYPE granularity, here are alternatives:

Option 1: AWS Cost and Usage Report (CUR)

CUR gives you the most granular data. Enable the AWS Cost and Usage Report, then query with Athena:

SELECT 
    line_item_usage_type,
    product_instance_type,
    savings_plan_savings_plan_a_r_n,
    SUM(savings_plan_savings_plan_effective_cost) AS sp_effective_cost,
    SUM(savings_plan_total_commitment_to_date) AS commitment,
    SUM(savings_plan_used_commitment) AS used_commitment
FROM cur_database.cur_table
WHERE savings_plan_savings_plan_a_r_n != ''
    AND line_item_line_item_type = 'SavingsPlanCoveredUsage'
    AND billing_period = '2024-05'
GROUP BY 1, 2, 3
ORDER BY sp_effective_cost DESC;

This gives you per-instance-type breakdown of Savings Plans utilization.

Option 2: GetCostAndUsage API with GroupBy

Use GetCostAndUsage instead, which supports INSTANCE_TYPE as a group-by dimension:

response = ce.get_cost_and_usage(
    TimePeriod={'Start': '2024-05-01', 'End': '2024-05-17'},
    Granularity='DAILY',
    Filter={
        'Dimensions': {
            'Key': 'RECORD_TYPE',
            'Values': ['SavingsPlanCoveredUsage']
        }
    },
    GroupBy=[
        {'Type': 'DIMENSION', 'Key': 'INSTANCE_TYPE'},
        {'Type': 'DIMENSION', 'Key': 'REGION'}
    ],
    Metrics=['AmortizedCost', 'UnblendedCost', 'UsageQuantity']
)

This won't give you the SP-specific utilization metrics (commitment, savings), but it will show you SP-covered costs broken down by instance type and region.

Option 3: GetSavingsPlansUtilizationDetails + Post-Processing

Use INSTANCE_TYPE_FAMILY as the filter, then correlate with GetCostAndUsage data to break down within the family:

# Get SP utilization by family
sp_util = ce.get_savings_plans_utilization_details(
    TimePeriod={'Start': '2024-05-01', 'End': '2024-05-17'},
    Filter={
        'Dimensions': {
            'Key': 'INSTANCE_TYPE_FAMILY',
            'Values': ['m6g']
        }
    }
)

Then join with CUR or GetCostAndUsage data to get instance-level granularity within that family.

Summary

APIINSTANCE_TYPE SupportSP Utilization Metrics
GetSavingsPlansUtilizationDetailsNo (INSTANCE_TYPE_FAMILY only)Yes
GetCostAndUsage (SavingsPlanCoveredUsage)Yes (GroupBy)Partial (costs only)
CUR + AthenaYesYes (full granularity)

CUR + Athena is the recommended approach for instance-type-level Savings Plans analysis.

References:

AWS
answered 24 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.