AWS Cost Explorer Service

2018/11/16 - AWS Cost Explorer Service - 1 new api methods

Changes  This release introduces a new operation called GetCostForecast operation, which allows you to programmatically access AWS Cost Explorer's forecasting engine and is now generally available.

GetCostForecast (new) Link ¶

Retrieves a forecast for how much Amazon Web Services predicts that you will spend over the forecast time period that you select, based on your past costs.

See also: AWS API Documentation

Request Syntax

client.get_cost_forecast(
    TimePeriod={
        'Start': 'string',
        'End': 'string'
    },
    Metric='BLENDED_COST'|'UNBLENDED_COST'|'AMORTIZED_COST'|'NET_UNBLENDED_COST'|'NET_AMORTIZED_COST'|'USAGE_QUANTITY'|'NORMALIZED_USAGE_AMOUNT',
    Granularity='DAILY'|'MONTHLY'|'HOURLY',
    Filter={
        'Or': [
            {'... recursive ...'},
        ],
        'And': [
            {'... recursive ...'},
        ],
        'Not': {'... recursive ...'},
        'Dimensions': {
            'Key': 'AZ'|'INSTANCE_TYPE'|'LINKED_ACCOUNT'|'OPERATION'|'PURCHASE_TYPE'|'REGION'|'SERVICE'|'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',
            'Values': [
                'string',
            ]
        },
        'Tags': {
            'Key': 'string',
            'Values': [
                'string',
            ]
        }
    },
    PredictionIntervalLevel=123
)
type TimePeriod

dict

param TimePeriod

[REQUIRED]

The period of time that you want the forecast to cover.

  • Start (string) -- [REQUIRED]

    The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , AWS retrieves cost and usage data starting at 2017-01-01 up to the end date.

  • End (string) -- [REQUIRED]

    The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if end is 2017-05-01 , AWS retrieves cost and usage data from the start date up to, but not including, 2017-05-01 .

type Metric

string

param Metric

[REQUIRED]

Which metric Cost Explorer uses to create your forecast. For more information about blended and unblended rates, see Why does the "blended" annotation appear on some line items in my bill? .

Valid values for a GetCostForecast call are the following:

  • AmortizedCost

  • BlendedCost

  • NetAmortizedCost

  • NetUnblendedCost

  • UnblendedCost

type Granularity

string

param Granularity

[REQUIRED]

How granular you want the forecast to be. You can get 3 months of DAILY forecasts or 12 months of MONTHLY forecasts.

type Filter

dict

param Filter

The filters that you want to use to filter your forecast. Cost Explorer API supports all of the Cost Explorer filters.

  • Or (list) --

    Return results that match either Dimension object.

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this: { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this: { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that creates an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • And (list) --

    Return results that match both Dimension objects.

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this: { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this: { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that creates an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • Not (dict) --

    Return results that don't match a Dimension object.

  • Dimensions (dict) --

    The specific Dimension to use for Expression .

    • Key (string) --

      The names of the metadata types that you can use to filter and group your results. For example, AZ returns a list of Availability Zones.

    • Values (list) --

      The metadata values that you can use to filter and group your results. You can use GetDimensionValues to find specific values.

      Valid values for the SERVICE dimension are Amazon Elastic Compute Cloud - Compute , Amazon Elasticsearch Service , Amazon ElastiCache , Amazon Redshift , and Amazon Relational Database Service .

      • (string) --

  • Tags (dict) --

    The specific Tag to use for Expression .

    • Key (string) --

      The key for a tag.

    • Values (list) --

      The specific value of a tag.

      • (string) --

type PredictionIntervalLevel

integer

param PredictionIntervalLevel

Cost Explorer always returns the mean forecast as a single point. You can request a prediction interval around the mean by specifying a confidence level. The higher the confidence level, the more confident Cost Explorer is about the actual value falling in the prediction interval. Higher confidence levels result in wider prediction intervals.

rtype

dict

returns

Response Syntax

{
    'Total': {
        'Amount': 'string',
        'Unit': 'string'
    },
    'ForecastResultsByTime': [
        {
            'TimePeriod': {
                'Start': 'string',
                'End': 'string'
            },
            'MeanValue': 'string',
            'PredictionIntervalLowerBound': 'string',
            'PredictionIntervalUpperBound': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • Total (dict) --

      How much you are forecasted to spend over the forecast period, in USD .

      • Amount (string) --

        The actual number that represents the metric.

      • Unit (string) --

        The unit that the metric is given in.

    • ForecastResultsByTime (list) --

      The forecasts for your query, in order. For DAILY forecasts, this is a list of days. For MONTHLY forecasts, this is a list of months.

      • (dict) --

        The forecast created for your query.

        • TimePeriod (dict) --

          The period of time that the forecast covers.

          • Start (string) --

            The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , AWS retrieves cost and usage data starting at 2017-01-01 up to the end date.

          • End (string) --

            The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if end is 2017-05-01 , AWS retrieves cost and usage data from the start date up to, but not including, 2017-05-01 .

        • MeanValue (string) --

          The mean value of the forecast.

        • PredictionIntervalLowerBound (string) --

          The lower limit for the prediction interval.

        • PredictionIntervalUpperBound (string) --

          The upper limit for the prediction interval.