Skip to content

put_recommendation_preferences

put_recommendation_preferences(
    resource_type: ResourceType,
    *,
    config_overrides: Optional[ComputeOptimizerClientConfig] = None,
    scope: Optional[Scope] = None,
    enhanced_infrastructure_metrics: Optional[EnhancedInfrastructureMetrics] = None,
    inferred_workload_types: Optional[InferredWorkloadTypesPreference] = None,
    external_metrics_preference: Optional[ExternalMetricsPreference] = None,
    look_back_period: Optional[LookBackPeriodPreference] = None,
    utilization_preferences: Optional[UtilizationPreferences] = None,
    preferred_resources: Optional[PreferredResources] = None,
    savings_estimation_mode: Optional[SavingsEstimationMode] = None,
) -> PutRecommendationPreferencesResponse

Creates a new recommendation preference or updates an existing recommendation preference, such as enhanced infrastructure metrics.

For more information, see Activating enhanced infrastructure metrics in the Compute Optimizer User Guide.

Parameters:

  • resource_type (ResourceType) –

    The target resource type of the recommendation preference to create.

    The Ec2Instance option encompasses standalone instances and instances that are part of Auto Scaling groups. The AutoScalingGroup option encompasses only instances that are part of an Auto Scaling group.

  • scope (Optional[Scope], default: None ) –

    An object that describes the scope of the recommendation preference to create.

    You can create recommendation preferences at the organization level (for management accounts of an organization only), account level, and resource level. For more information, see Activating enhanced infrastructure metrics in the Compute Optimizer User Guide.

    You cannot create recommendation preferences for Auto Scaling groups at the organization and account levels. You can create recommendation preferences for Auto Scaling groups only at the resource level by specifying a scope name of ResourceArn and a scope value of the Auto Scaling group Amazon Resource Name (ARN). This will configure the preference for all instances that are part of the specified Auto Scaling group. You also cannot create recommendation preferences at the resource level for instances that are part of an Auto Scaling group. You can create recommendation preferences at the resource level only for standalone instances.

  • enhanced_infrastructure_metrics (Optional[EnhancedInfrastructureMetrics], default: None ) –

    The status of the enhanced infrastructure metrics recommendation preference to create or update.

    Specify the Active status to activate the preference, or specify Inactive to deactivate the preference.

    For more information, see Enhanced infrastructure metrics in the Compute Optimizer User Guide.

  • inferred_workload_types (Optional[InferredWorkloadTypesPreference], default: None ) –

    The status of the inferred workload types recommendation preference to create or update.

    The inferred workload type feature is active by default. To deactivate it, create a recommendation preference.

    Specify the Inactive status to deactivate the feature, or specify Active to activate it.

    For more information, see Inferred workload types in the Compute Optimizer User Guide.

  • external_metrics_preference (Optional[ExternalMetricsPreference], default: None ) –

    The provider of the external metrics recommendation preference to create or update.

    Specify a valid provider in the source field to activate the preference. To delete this preference, see the DeleteRecommendationPreferences action.

    This preference can only be set for the Ec2Instance resource type.

    For more information, see External metrics ingestion in the Compute Optimizer User Guide.

  • look_back_period (Optional[LookBackPeriodPreference], default: None ) –

    The preference to control the number of days the utilization metrics of the Amazon Web Services resource are analyzed. When this preference isn't specified, we use the default value DAYS_14.

    You can only set this preference for the Amazon EC2 instance, Auto Scaling group, Amazon EBS volume, Amazon ECS service on Fargate, Amazon RDS DB instance, and Aurora DB cluster storage resource types.

    • Lookback period preferences for Amazon EC2 instances, Amazon EBS volumes, Amazon ECS services, Amazon RDS DB instances, and Aurora DB cluster storage resource types can be set at the organization, account, and resource levels.

    • Auto Scaling group lookback preferences can only be set at the resource level.

    • Amazon EBS volume lookback preferences can be set at the organization, account, and resource levels.

    • Amazon ECS service on Fargate lookback preferences can be set at the organization, account, and resource levels.

    • Amazon RDS DB instance lookback preferences can be set at the organization, account, and resource levels.

    • Aurora DB cluster storage lookback preferences can be set at the organization, account, and resource levels.

    • Changing the lookback period for Amazon EBS volumes to 14 days does not affect the 32-day lookback period used to determine whether an Amazon EBS volume is unattached.

  • utilization_preferences (Optional[UtilizationPreferences], default: None ) –

    The preference to control the resource’s CPU utilization threshold, CPU utilization headroom, and memory utilization headroom. When this preference isn't specified, we use the following default values.

    CPU utilization:

    • P99_5 for threshold

    • PERCENT_20 for headroom

    Memory utilization:

    • PERCENT_20 for headroom

    • You can only set CPU and memory utilization preferences for the Amazon EC2 instance resource type.

    • The threshold setting isn’t available for memory utilization.

  • preferred_resources (Optional[PreferredResources], default: None ) –

    The preference to control which resource type values are considered when generating rightsizing recommendations. You can specify this preference as a combination of include and exclude lists. You must specify either an includeList or excludeList. If the preference is an empty set of resource type values, an error occurs.

    You can only set this preference for the Amazon EC2 instance, Auto Scaling group, Amazon EBS volume, Amazon ECS service, Amazon RDS DB instance, and Aurora DB cluster storage resource types.

  • savings_estimation_mode (Optional[SavingsEstimationMode], default: None ) –

    The status of the savings estimation mode preference to create or update.

    Specify the AfterDiscounts status to activate the preference, or specify BeforeDiscounts to deactivate the preference.

    Only the account manager or delegated administrator of your organization can activate this preference.

    For more information, see Savings estimation mode in the Compute Optimizer User Guide.

Raises:

Source code in docs_src/capo_compute_optimizer/_services/compute_optimizer.py
def put_recommendation_preferences(
    self,
    resource_type: "capo_compute_optimizer.types.resource_type.ResourceType",
    *,
    config_overrides: Optional[ComputeOptimizerClientConfig] = None,
    scope: Optional["capo_compute_optimizer.types.scope.Scope"] = None,
    enhanced_infrastructure_metrics: Optional[
        "capo_compute_optimizer.types.enhanced_infrastructure_metrics.EnhancedInfrastructureMetrics"
    ] = None,
    inferred_workload_types: Optional[
        "capo_compute_optimizer.types.inferred_workload_types_preference.InferredWorkloadTypesPreference"
    ] = None,
    external_metrics_preference: Optional[
        "capo_compute_optimizer.types.external_metrics_preference.ExternalMetricsPreference"
    ] = None,
    look_back_period: Optional[
        "capo_compute_optimizer.types.look_back_period_preference.LookBackPeriodPreference"
    ] = None,
    utilization_preferences: Optional[
        "capo_compute_optimizer.types.utilization_preferences.UtilizationPreferences"
    ] = None,
    preferred_resources: Optional[
        "capo_compute_optimizer.types.preferred_resources.PreferredResources"
    ] = None,
    savings_estimation_mode: Optional[
        "capo_compute_optimizer.types.savings_estimation_mode.SavingsEstimationMode"
    ] = None,
) -> "capo_compute_optimizer.types.put_recommendation_preferences_response.PutRecommendationPreferencesResponse":
    """<p>Creates a new recommendation preference or updates an existing recommendation preference, such as enhanced infrastructure metrics.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/enhanced-infrastructure-metrics.html">Activating enhanced infrastructure metrics</a> in the <i>Compute Optimizer User Guide</i>.</p>

    Args:
        resource_type: <p>The target resource type of the recommendation preference to create.</p> <p>The <code>Ec2Instance</code> option encompasses standalone instances and instances that are part of Auto Scaling groups. The <code>AutoScalingGroup</code> option encompasses only instances that are part of an Auto Scaling group.</p>
        scope: <p>An object that describes the scope of the recommendation preference to create.</p> <p>You can create recommendation preferences at the organization level (for management accounts of an organization only), account level, and resource level. For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/enhanced-infrastructure-metrics.html">Activating enhanced infrastructure metrics</a> in the <i>Compute Optimizer User Guide</i>.</p> <note> <p>You cannot create recommendation preferences for Auto Scaling groups at the organization and account levels. You can create recommendation preferences for Auto Scaling groups only at the resource level by specifying a scope name of <code>ResourceArn</code> and a scope value of the Auto Scaling group Amazon Resource Name (ARN). This will configure the preference for all instances that are part of the specified Auto Scaling group. You also cannot create recommendation preferences at the resource level for instances that are part of an Auto Scaling group. You can create recommendation preferences at the resource level only for standalone instances.</p> </note>
        enhanced_infrastructure_metrics: <p>The status of the enhanced infrastructure metrics recommendation preference to create or update.</p> <p>Specify the <code>Active</code> status to activate the preference, or specify <code>Inactive</code> to deactivate the preference.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/enhanced-infrastructure-metrics.html">Enhanced infrastructure metrics</a> in the <i>Compute Optimizer User Guide</i>.</p>
        inferred_workload_types: <p>The status of the inferred workload types recommendation preference to create or update.</p> <note> <p>The inferred workload type feature is active by default. To deactivate it, create a recommendation preference.</p> </note> <p>Specify the <code>Inactive</code> status to deactivate the feature, or specify <code>Active</code> to activate it.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/inferred-workload-types.html">Inferred workload types</a> in the <i>Compute Optimizer User Guide</i>.</p>
        external_metrics_preference: <p>The provider of the external metrics recommendation preference to create or update.</p> <p>Specify a valid provider in the <code>source</code> field to activate the preference. To delete this preference, see the <a>DeleteRecommendationPreferences</a> action.</p> <p>This preference can only be set for the <code>Ec2Instance</code> resource type.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/external-metrics-ingestion.html">External metrics ingestion</a> in the <i>Compute Optimizer User Guide</i>.</p>
        look_back_period: <p> The preference to control the number of days the utilization metrics of the Amazon Web Services resource are analyzed. When this preference isn't specified, we use the default value <code>DAYS_14</code>. </p> <p>You can only set this preference for the Amazon EC2 instance, Auto Scaling group, Amazon EBS volume, Amazon ECS service on Fargate, Amazon RDS DB instance, and Aurora DB cluster storage resource types. </p> <note> <ul> <li> <p>Lookback period preferences for Amazon EC2 instances, Amazon EBS volumes, Amazon ECS services, Amazon RDS DB instances, and Aurora DB cluster storage resource types can be set at the organization, account, and resource levels.</p> </li> <li> <p>Auto Scaling group lookback preferences can only be set at the resource level.</p> </li> <li> <p>Amazon EBS volume lookback preferences can be set at the organization, account, and resource levels.</p> </li> <li> <p>Amazon ECS service on Fargate lookback preferences can be set at the organization, account, and resource levels.</p> </li> <li> <p>Amazon RDS DB instance lookback preferences can be set at the organization, account, and resource levels.</p> </li> <li> <p>Aurora DB cluster storage lookback preferences can be set at the organization, account, and resource levels.</p> </li> <li> <p>Changing the lookback period for Amazon EBS volumes to 14 days does not affect the 32-day lookback period used to determine whether an Amazon EBS volume is unattached.</p> </li> </ul> </note>
        utilization_preferences: <p> The preference to control the resource’s CPU utilization threshold, CPU utilization headroom, and memory utilization headroom. When this preference isn't specified, we use the following default values. </p> <p>CPU utilization:</p> <ul> <li> <p> <code>P99_5</code> for threshold</p> </li> <li> <p> <code>PERCENT_20</code> for headroom</p> </li> </ul> <p>Memory utilization:</p> <ul> <li> <p> <code>PERCENT_20</code> for headroom</p> </li> </ul> <note> <ul> <li> <p>You can only set CPU and memory utilization preferences for the Amazon EC2 instance resource type.</p> </li> <li> <p>The threshold setting isn’t available for memory utilization.</p> </li> </ul> </note>
        preferred_resources: <p> The preference to control which resource type values are considered when generating rightsizing recommendations. You can specify this preference as a combination of include and exclude lists. You must specify either an <code>includeList</code> or <code>excludeList</code>. If the preference is an empty set of resource type values, an error occurs. </p> <note> <p>You can only set this preference for the Amazon EC2 instance, Auto Scaling group, Amazon EBS volume, Amazon ECS service, Amazon RDS DB instance, and Aurora DB cluster storage resource types.</p> </note>
        savings_estimation_mode: <p> The status of the savings estimation mode preference to create or update. </p> <p>Specify the <code>AfterDiscounts</code> status to activate the preference, or specify <code>BeforeDiscounts</code> to deactivate the preference.</p> <p>Only the account manager or delegated administrator of your organization can activate this preference.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/savings-estimation-mode.html"> Savings estimation mode</a> in the <i>Compute Optimizer User Guide</i>.</p>

    Raises:
        capo_compute_optimizer.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_compute_optimizer.errors.internal_server_exception.InternalServerException: <p>An internal error has occurred. Try your call again.</p>
        capo_compute_optimizer.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value supplied for the input parameter is out of range or not valid.</p>
        capo_compute_optimizer.errors.missing_authentication_token.MissingAuthenticationToken: <p>The request must contain either a valid (registered) Amazon Web Services access key ID or X.509 certificate.</p>
        capo_compute_optimizer.errors.opt_in_required_exception.OptInRequiredException: <p>The account is not opted in to Compute Optimizer.</p>
        capo_compute_optimizer.errors.resource_not_found_exception.ResourceNotFoundException: <p>A resource that is required for the action doesn't exist.</p>
        capo_compute_optimizer.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request has failed due to a temporary failure of the server.</p>
        capo_compute_optimizer.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_compute_optimizer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_compute_optimizer.types.put_recommendation_preferences_request.PutRecommendationPreferencesRequest]",
    ) -> OperationResponse[
        "capo_compute_optimizer.types.put_recommendation_preferences_response.PutRecommendationPreferencesResponse"
    ]:
        import capo_compute_optimizer._operations.compute_optimizer_service.put_recommendation_preferences

        output, http_response = (
            capo_compute_optimizer._operations.compute_optimizer_service.put_recommendation_preferences.put_recommendation_preferences(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutRecommendationPreferences")
    )
    input_: capo_compute_optimizer.types.put_recommendation_preferences_request.PutRecommendationPreferencesRequest = {
        "resource_type": resource_type
    }
    if scope is not None:
        input_["scope"] = scope
    if enhanced_infrastructure_metrics is not None:
        input_["enhanced_infrastructure_metrics"] = enhanced_infrastructure_metrics
    if inferred_workload_types is not None:
        input_["inferred_workload_types"] = inferred_workload_types
    if external_metrics_preference is not None:
        input_["external_metrics_preference"] = external_metrics_preference
    if look_back_period is not None:
        input_["look_back_period"] = look_back_period
    if utilization_preferences is not None:
        input_["utilization_preferences"] = utilization_preferences
    if preferred_resources is not None:
        input_["preferred_resources"] = preferred_resources
    if savings_estimation_mode is not None:
        input_["savings_estimation_mode"] = savings_estimation_mode

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