GetSavingsPlansCoverageCommand

Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by a Savings Plan. An organization’s management account can see the coverage of the associated member accounts. This supports dimensions, Cost Categories, and nested expressions. For any time period, you can filter data for Savings Plans usage with the following dimensions:

  • LINKED_ACCOUNT

  • REGION

  • SERVICE

  • INSTANCE_FAMILY

To determine valid values for a dimension, use the GetDimensionValues operation.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CostExplorerClient, GetSavingsPlansCoverageCommand } from "@aws-sdk/client-cost-explorer"; // ES Modules import
// const { CostExplorerClient, GetSavingsPlansCoverageCommand } = require("@aws-sdk/client-cost-explorer"); // CommonJS import
const client = new CostExplorerClient(config);
const input = { // GetSavingsPlansCoverageRequest
  TimePeriod: { // DateInterval
    Start: "STRING_VALUE", // required
    End: "STRING_VALUE", // required
  },
  GroupBy: [ // GroupDefinitions
    { // GroupDefinition
      Type: "DIMENSION" || "TAG" || "COST_CATEGORY",
      Key: "STRING_VALUE",
    },
  ],
  Granularity: "DAILY" || "MONTHLY" || "HOURLY",
  Filter: { // Expression
    Or: [ // Expressions
      {
        Or: [
          "<Expression>",
        ],
        And: [
          "<Expression>",
        ],
        Not: "<Expression>",
        Dimensions: { // DimensionValues
          Key: "AZ" || "INSTANCE_TYPE" || "LINKED_ACCOUNT" || "LINKED_ACCOUNT_NAME" || "OPERATION" || "PURCHASE_TYPE" || "REGION" || "SERVICE" || "SERVICE_CODE" || "USAGE_TYPE" || "USAGE_TYPE_GROUP" || "RECORD_TYPE" || "OPERATING_SYSTEM" || "TENANCY" || "SCOPE" || "PLATFORM" || "SUBSCRIPTION_ID" || "LEGAL_ENTITY_NAME" || "DEPLOYMENT_OPTION" || "DATABASE_ENGINE" || "CACHE_ENGINE" || "INSTANCE_TYPE_FAMILY" || "BILLING_ENTITY" || "RESERVATION_ID" || "RESOURCE_ID" || "RIGHTSIZING_TYPE" || "SAVINGS_PLANS_TYPE" || "SAVINGS_PLAN_ARN" || "PAYMENT_OPTION" || "AGREEMENT_END_DATE_TIME_AFTER" || "AGREEMENT_END_DATE_TIME_BEFORE" || "INVOICING_ENTITY" || "ANOMALY_TOTAL_IMPACT_ABSOLUTE" || "ANOMALY_TOTAL_IMPACT_PERCENTAGE",
          Values: [ // Values
            "STRING_VALUE",
          ],
          MatchOptions: [ // MatchOptions
            "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
          ],
        },
        Tags: { // TagValues
          Key: "STRING_VALUE",
          Values: [
            "STRING_VALUE",
          ],
          MatchOptions: [
            "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
          ],
        },
        CostCategories: { // CostCategoryValues
          Key: "STRING_VALUE",
          Values: [
            "STRING_VALUE",
          ],
          MatchOptions: [
            "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
          ],
        },
      },
    ],
    And: [
      "<Expression>",
    ],
    Not: "<Expression>",
    Dimensions: {
      Key: "AZ" || "INSTANCE_TYPE" || "LINKED_ACCOUNT" || "LINKED_ACCOUNT_NAME" || "OPERATION" || "PURCHASE_TYPE" || "REGION" || "SERVICE" || "SERVICE_CODE" || "USAGE_TYPE" || "USAGE_TYPE_GROUP" || "RECORD_TYPE" || "OPERATING_SYSTEM" || "TENANCY" || "SCOPE" || "PLATFORM" || "SUBSCRIPTION_ID" || "LEGAL_ENTITY_NAME" || "DEPLOYMENT_OPTION" || "DATABASE_ENGINE" || "CACHE_ENGINE" || "INSTANCE_TYPE_FAMILY" || "BILLING_ENTITY" || "RESERVATION_ID" || "RESOURCE_ID" || "RIGHTSIZING_TYPE" || "SAVINGS_PLANS_TYPE" || "SAVINGS_PLAN_ARN" || "PAYMENT_OPTION" || "AGREEMENT_END_DATE_TIME_AFTER" || "AGREEMENT_END_DATE_TIME_BEFORE" || "INVOICING_ENTITY" || "ANOMALY_TOTAL_IMPACT_ABSOLUTE" || "ANOMALY_TOTAL_IMPACT_PERCENTAGE",
      Values: [
        "STRING_VALUE",
      ],
      MatchOptions: [
        "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
      ],
    },
    Tags: {
      Key: "STRING_VALUE",
      Values: [
        "STRING_VALUE",
      ],
      MatchOptions: [
        "EQUALS" || "ABSENT" || "STARTS_WITH" || "ENDS_WITH" || "CONTAINS" || "CASE_SENSITIVE" || "CASE_INSENSITIVE" || "GREATER_THAN_OR_EQUAL",
      ],
    },
    CostCategories: {
      Key: "STRING_VALUE",
      Values: "<Values>",
      MatchOptions: "<MatchOptions>",
    },
  },
  Metrics: [ // MetricNames
    "STRING_VALUE",
  ],
  NextToken: "STRING_VALUE",
  MaxResults: Number("int"),
  SortBy: { // SortDefinition
    Key: "STRING_VALUE", // required
    SortOrder: "ASCENDING" || "DESCENDING",
  },
};
const command = new GetSavingsPlansCoverageCommand(input);
const response = await client.send(command);
// { // GetSavingsPlansCoverageResponse
//   SavingsPlansCoverages: [ // SavingsPlansCoverages // required
//     { // SavingsPlansCoverage
//       Attributes: { // Attributes
//         "<keys>": "STRING_VALUE",
//       },
//       Coverage: { // SavingsPlansCoverageData
//         SpendCoveredBySavingsPlans: "STRING_VALUE",
//         OnDemandCost: "STRING_VALUE",
//         TotalCost: "STRING_VALUE",
//         CoveragePercentage: "STRING_VALUE",
//       },
//       TimePeriod: { // DateInterval
//         Start: "STRING_VALUE", // required
//         End: "STRING_VALUE", // required
//       },
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

GetSavingsPlansCoverageCommand Input

Parameter
Type
Description
TimePeriod
Required
DateInterval | undefined

The time period that you want the usage and costs for. The Start date must be within 13 months. The End date must be after the Start date, and before the current date. Future dates can't be used as an End date.

Filter
Expression | undefined

Filters Savings Plans coverage data by dimensions. You can filter data for Savings Plans usage with the following dimensions:

  • LINKED_ACCOUNT

  • REGION

  • SERVICE

  • INSTANCE_FAMILY

GetSavingsPlansCoverage uses the same Expression  object as the other operations, but only AND is supported among each dimension. If there are multiple values for a dimension, they are OR'd together.

Cost category is also supported.

Granularity
Granularity | undefined

The granularity of the Amazon Web Services cost data for your Savings Plans. Granularity can't be set if GroupBy is set.

The GetSavingsPlansCoverage operation supports only DAILY and MONTHLY granularities.

GroupBy
GroupDefinition[] | undefined

You can group the data using the attributes INSTANCE_FAMILY, REGION, or SERVICE.

MaxResults
number | undefined

The number of items to be returned in a response. The default is 20, with a minimum value of 1.

Metrics
string[] | undefined

The measurement that you want your Savings Plans coverage reported in. The only valid value is SpendCoveredBySavingsPlans.

NextToken
string | undefined

The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.

SortBy
SortDefinition | undefined

The value that you want to sort the data by.

The following values are supported for Key:

  • SpendCoveredBySavingsPlan

  • OnDemandCost

  • CoveragePercentage

  • TotalCost

  • InstanceFamily

  • Region

  • Service

The supported values for SortOrder are ASCENDING and DESCENDING.

GetSavingsPlansCoverageCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
SavingsPlansCoverages
Required
SavingsPlansCoverage[] | undefined

The amount of spend that your Savings Plans covered.

NextToken
string | undefined

The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.

Throws

Name
Fault
Details
DataUnavailableException
client

The requested data is unavailable.

InvalidNextTokenException
client

The pagination token is invalid. Try again without a pagination token.

LimitExceededException
client

You made too many calls in a short period of time. Try again later.

CostExplorerServiceException
Base exception class for all service exceptions from CostExplorer service.