Skip to content

get_cost_forecast

get_cost_forecast(
    time_period: DateInterval,
    metric: Metric,
    granularity: Granularity,
    *,
    config_overrides: Optional[CostExplorerClientConfig] = None,
    filter: Optional[Expression] = None,
    billing_view_arn: Optional[BillingViewArn] = None,
    prediction_interval_level: Optional[PredictionIntervalLevel] = None,
) -> GetCostForecastResponse

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.

Parameters:

  • time_period (DateInterval) –

    The period of time that you want the forecast to cover. The start date must be equal to or no later than the current date to avoid a validation error.

  • metric (Metric) –

    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:

    • AMORTIZED_COST

    • BLENDED_COST

    • NET_AMORTIZED_COST

    • NET_UNBLENDED_COST

    • UNBLENDED_COST

  • granularity (Granularity) –

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

    The GetCostForecast operation supports only DAILY and MONTHLY granularities.

  • filter (Optional[Expression], default: None ) –

    The filters that you want to use to filter your forecast. The GetCostForecast API supports filtering by the following dimensions:

    • 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

    • INSTANCE_TYPE_FAMILY

    • BILLING_ENTITY

    • RESERVATION_ID

    • SAVINGS_PLAN_ARN

  • billing_view_arn (Optional[BillingViewArn], default: None ) –

    The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.

  • prediction_interval_level (Optional[PredictionIntervalLevel], default: None ) –

    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.

Raises:

Source code in docs_src/capo_cost_explorer/_services/cost_explorer.py
def get_cost_forecast(
    self,
    time_period: "capo_cost_explorer.types.date_interval.DateInterval",
    metric: "capo_cost_explorer.types.metric.Metric",
    granularity: "capo_cost_explorer.types.granularity.Granularity",
    *,
    config_overrides: Optional[CostExplorerClientConfig] = None,
    filter: Optional["capo_cost_explorer.types.expression.Expression"] = None,
    billing_view_arn: Optional[
        "capo_cost_explorer.types.billing_view_arn.BillingViewArn"
    ] = None,
    prediction_interval_level: Optional[
        "capo_cost_explorer.types.prediction_interval_level.PredictionIntervalLevel"
    ] = None,
) -> "capo_cost_explorer.types.get_cost_forecast_response.GetCostForecastResponse":
    """<p>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. </p>

    Args:
        time_period: <p>The period of time that you want the forecast to cover. The start date must be equal to or no later than the current date to avoid a validation error.</p>
        metric: <p>Which metric Cost Explorer uses to create your forecast. For more information about blended and unblended rates, see <a href="http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/">Why does the "blended" annotation appear on some line items in my bill?</a>. </p> <p>Valid values for a <code>GetCostForecast</code> call are the following:</p> <ul> <li> <p>AMORTIZED_COST</p> </li> <li> <p>BLENDED_COST</p> </li> <li> <p>NET_AMORTIZED_COST</p> </li> <li> <p>NET_UNBLENDED_COST</p> </li> <li> <p>UNBLENDED_COST</p> </li> </ul>
        granularity: <p>How granular you want the forecast to be. You can get 3 months of <code>DAILY</code> forecasts or 18 months of <code>MONTHLY</code> forecasts.</p> <p>The <code>GetCostForecast</code> operation supports only <code>DAILY</code> and <code>MONTHLY</code> granularities.</p>
        filter: <p>The filters that you want to use to filter your forecast. The <code>GetCostForecast</code> API supports filtering by the following dimensions:</p> <ul> <li> <p> <code>AZ</code> </p> </li> <li> <p> <code>INSTANCE_TYPE</code> </p> </li> <li> <p> <code>LINKED_ACCOUNT</code> </p> </li> <li> <p> <code>OPERATION</code> </p> </li> <li> <p> <code>PURCHASE_TYPE</code> </p> </li> <li> <p> <code>REGION</code> </p> </li> <li> <p> <code>SERVICE</code> </p> </li> <li> <p> <code>USAGE_TYPE</code> </p> </li> <li> <p> <code>USAGE_TYPE_GROUP</code> </p> </li> <li> <p> <code>RECORD_TYPE</code> </p> </li> <li> <p> <code>OPERATING_SYSTEM</code> </p> </li> <li> <p> <code>TENANCY</code> </p> </li> <li> <p> <code>SCOPE</code> </p> </li> <li> <p> <code>PLATFORM</code> </p> </li> <li> <p> <code>SUBSCRIPTION_ID</code> </p> </li> <li> <p> <code>LEGAL_ENTITY_NAME</code> </p> </li> <li> <p> <code>DEPLOYMENT_OPTION</code> </p> </li> <li> <p> <code>DATABASE_ENGINE</code> </p> </li> <li> <p> <code>INSTANCE_TYPE_FAMILY</code> </p> </li> <li> <p> <code>BILLING_ENTITY</code> </p> </li> <li> <p> <code>RESERVATION_ID</code> </p> </li> <li> <p> <code>SAVINGS_PLAN_ARN</code> </p> </li> </ul>
        billing_view_arn: <p>The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.</p>
        prediction_interval_level: <p>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.</p>

    Raises:
        capo_cost_explorer.errors.billing_view_health_status_exception.BillingViewHealthStatusException: <p> The billing view status must be <code>HEALTHY</code> to perform this action. Try again when the status is <code>HEALTHY</code>. </p>
        capo_cost_explorer.errors.data_unavailable_exception.DataUnavailableException: <p>The requested data is unavailable.</p>
        capo_cost_explorer.errors.limit_exceeded_exception.LimitExceededException: <p>You made too many calls in a short period of time. Try again later.</p>
        capo_cost_explorer.errors.resource_not_found_exception.ResourceNotFoundException: <p> The specified ARN in the request doesn't exist. </p>
        capo_cost_explorer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cost_explorer.types.get_cost_forecast_request.GetCostForecastRequest]",
    ) -> OperationResponse[
        "capo_cost_explorer.types.get_cost_forecast_response.GetCostForecastResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_cost_forecast

        output, http_response = (
            capo_cost_explorer._operations.aws_insights_index_service.get_cost_forecast.get_cost_forecast(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetCostForecast")
    )
    input_: capo_cost_explorer.types.get_cost_forecast_request.GetCostForecastRequest = {
        "time_period": time_period,
        "metric": metric,
        "granularity": granularity,
    }
    if filter is not None:
        input_["filter"] = filter
    if billing_view_arn is not None:
        input_["billing_view_arn"] = billing_view_arn
    if prediction_interval_level is not None:
        input_["prediction_interval_level"] = prediction_interval_level

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output