Skip to content

update_capacity_provider

update_capacity_provider(
    name: String,
    *,
    config_overrides: Optional[ECSClientConfig] = None,
    cluster: Optional[String] = None,
    auto_scaling_group_provider: Optional[AutoScalingGroupProviderUpdate] = None,
    managed_instances_provider: Optional[
        UpdateManagedInstancesProviderConfiguration
    ] = None,
) -> UpdateCapacityProviderResponse

Modifies the parameters for a capacity provider.

These changes only apply to new Amazon ECS Managed Instances, or EC2 instances, not existing ones.

Parameters:

  • name (String) –

    The name of the capacity provider to update.

  • cluster (Optional[String], default: None ) –

    The name of the cluster that contains the capacity provider to update. Managed instances capacity providers are cluster-scoped and can only be updated within their associated cluster.

  • auto_scaling_group_provider (Optional[AutoScalingGroupProviderUpdate], default: None ) –

    An object that represent the parameters to update for the Auto Scaling group capacity provider.

  • managed_instances_provider (Optional[UpdateManagedInstancesProviderConfiguration], default: None ) –

    The updated configuration for the Amazon ECS Managed Instances provider. You can modify the infrastructure role, instance launch template, and tag propagation settings. Changes take effect for new instances launched after the update.

Raises:

  • AccessDeniedException –

    You don't have authorization to perform the requested action.

  • ClientException –

    These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.

  • ClusterNotFoundException –

    The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.

  • InvalidParameterException –

    The specified parameter isn't valid. Review the available parameters for the API request.

    For more information about service event errors, see Amazon ECS service event messages.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnsupportedFeatureException –

    The specified task isn't supported in this Region.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To update a capacity provider's parameters This example updates the targetCapacity and instanceWarmupPeriod parameters for the capacity provider MyCapacityProvider to 90 and 150 respectively.

>>> client.update_capacity_provider(name='MyCapacityProvider', auto_scaling_group_provider={'managedScaling': {'status': 'ENABLED', 'targetCapacity': 90, 'instanceWarmupPeriod': 150}})
Source code in docs_src/capo_ecs/_services/ecs.py
def update_capacity_provider(
    self,
    name: "capo_ecs.types.string.String",
    *,
    config_overrides: Optional[ECSClientConfig] = None,
    cluster: Optional["capo_ecs.types.string.String"] = None,
    auto_scaling_group_provider: Optional[
        "capo_ecs.types.auto_scaling_group_provider_update.AutoScalingGroupProviderUpdate"
    ] = None,
    managed_instances_provider: Optional[
        "capo_ecs.types.update_managed_instances_provider_configuration.UpdateManagedInstancesProviderConfiguration"
    ] = None,
) -> "capo_ecs.types.update_capacity_provider_response.UpdateCapacityProviderResponse":
    """<p>Modifies the parameters for a capacity provider.</p> <p>These changes only apply to new Amazon ECS Managed Instances, or EC2 instances, not existing ones.</p>

    Args:
        name: <p>The name of the capacity provider to update.</p>
        cluster: <p>The name of the cluster that contains the capacity provider to update. Managed instances capacity providers are cluster-scoped and can only be updated within their associated cluster.</p>
        auto_scaling_group_provider: <p>An object that represent the parameters to update for the Auto Scaling group capacity provider.</p>
        managed_instances_provider: <p>The updated configuration for the Amazon ECS Managed Instances provider. You can modify the infrastructure role, instance launch template, and tag propagation settings. Changes take effect for new instances launched after the update.</p>

    Raises:
        capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
        capo_ecs.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.</p>
        capo_ecs.errors.cluster_not_found_exception.ClusterNotFoundException: <p>The specified cluster wasn't found. You can view your available clusters with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html">ListClusters</a>. Amazon ECS clusters are Region specific.</p>
        capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
        capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_ecs.errors.unsupported_feature_exception.UnsupportedFeatureException: <p>The specified task isn't supported in this Region.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To update a capacity provider's parameters
        This example updates the targetCapacity and instanceWarmupPeriod parameters for the capacity provider MyCapacityProvider to 90 and 150 respectively.

        >>> client.update_capacity_provider(name='MyCapacityProvider', auto_scaling_group_provider={'managedScaling': {'status': 'ENABLED', 'targetCapacity': 90, 'instanceWarmupPeriod': 150}})
    """

    def _handler(
        req: "OperationRequest[capo_ecs.types.update_capacity_provider_request.UpdateCapacityProviderRequest]",
    ) -> OperationResponse[
        "capo_ecs.types.update_capacity_provider_response.UpdateCapacityProviderResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.update_capacity_provider

        output, http_response = (
            capo_ecs._operations.amazon_ec2_container_service_v20141113.update_capacity_provider.update_capacity_provider(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateCapacityProvider")
    )
    input_: capo_ecs.types.update_capacity_provider_request.UpdateCapacityProviderRequest = {
        "name": name
    }
    if cluster is not None:
        input_["cluster"] = cluster
    if auto_scaling_group_provider is not None:
        input_["auto_scaling_group_provider"] = auto_scaling_group_provider
    if managed_instances_provider is not None:
        input_["managed_instances_provider"] = managed_instances_provider

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