Skip to content

get_rightsizing_recommendation

get_rightsizing_recommendation(
    service: GenericString,
    *,
    config_overrides: Optional[CostExplorerClientConfig] = None,
    filter: Optional[Expression] = None,
    configuration: Optional[RightsizingRecommendationConfiguration] = None,
    page_size: Optional[RecommendationsPageSize] = None,
    next_page_token: Optional[NextPageToken] = None,
) -> GetRightsizingRecommendationResponse

Creates recommendations that help you save cost by identifying idle and underutilized Amazon EC2 instances.

Recommendations are generated to either downsize or terminate instances, along with providing savings detail and metrics. For more information about calculation and function, see Optimizing Your Cost with Rightsizing Recommendations in the Billing and Cost Management User Guide.

Parameters:

  • configuration (Optional[RightsizingRecommendationConfiguration], default: None ) –

    You can use Configuration to customize recommendations across two attributes. You can choose to view recommendations for instances within the same instance families or across different instance families. You can also choose to view your estimated savings that are associated with recommendations with consideration of existing Savings Plans or RI benefits, or neither.

  • service (GenericString) –

    The specific service that you want recommendations for. The only valid value for GetRightsizingRecommendation is "AmazonEC2".

  • page_size (Optional[RecommendationsPageSize], default: None ) –

    The number of recommendations that you want returned in a single response object.

  • next_page_token (Optional[NextPageToken], default: None ) –

    The pagination token that indicates the next set of results that you want to retrieve.

Raises:

Source code in docs_src/capo_cost_explorer/_services/cost_explorer.py
def get_rightsizing_recommendation(
    self,
    service: "capo_cost_explorer.types.generic_string.GenericString",
    *,
    config_overrides: Optional[CostExplorerClientConfig] = None,
    filter: Optional["capo_cost_explorer.types.expression.Expression"] = None,
    configuration: Optional[
        "capo_cost_explorer.types.rightsizing_recommendation_configuration.RightsizingRecommendationConfiguration"
    ] = None,
    page_size: Optional[
        "capo_cost_explorer.types.recommendations_page_size.RecommendationsPageSize"
    ] = None,
    next_page_token: Optional[
        "capo_cost_explorer.types.next_page_token.NextPageToken"
    ] = None,
) -> "capo_cost_explorer.types.get_rightsizing_recommendation_response.GetRightsizingRecommendationResponse":
    """<p>Creates recommendations that help you save cost by identifying idle and underutilized Amazon EC2 instances.</p> <p>Recommendations are generated to either downsize or terminate instances, along with providing savings detail and metrics. For more information about calculation and function, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-rightsizing.html">Optimizing Your Cost with Rightsizing Recommendations</a> in the <i>Billing and Cost Management User Guide</i>.</p>

    Args:
        configuration: <p>You can use Configuration to customize recommendations across two attributes. You can choose to view recommendations for instances within the same instance families or across different instance families. You can also choose to view your estimated savings that are associated with recommendations with consideration of existing Savings Plans or RI benefits, or neither. </p>
        service: <p>The specific service that you want recommendations for. The only valid value for <code>GetRightsizingRecommendation</code> is "<code>AmazonEC2</code>".</p>
        page_size: <p>The number of recommendations that you want returned in a single response object.</p>
        next_page_token: <p>The pagination token that indicates the next set of results that you want to retrieve.</p>

    Raises:
        capo_cost_explorer.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The pagination token is invalid. Try again without a pagination token.</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.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cost_explorer.types.get_rightsizing_recommendation_request.GetRightsizingRecommendationRequest]",
    ) -> OperationResponse[
        "capo_cost_explorer.types.get_rightsizing_recommendation_response.GetRightsizingRecommendationResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_rightsizing_recommendation

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetRightsizingRecommendation")
    )
    input_: capo_cost_explorer.types.get_rightsizing_recommendation_request.GetRightsizingRecommendationRequest = {
        "service": service
    }
    if filter is not None:
        input_["filter"] = filter
    if configuration is not None:
        input_["configuration"] = configuration
    if page_size is not None:
        input_["page_size"] = page_size
    if next_page_token is not None:
        input_["next_page_token"] = next_page_token

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