Skip to content

update_cluster_settings

update_cluster_settings(
    cluster: String,
    settings: ClusterSettings,
    *,
    config_overrides: Optional[ECSClientConfig] = None,
) -> UpdateClusterSettingsResponse

Modifies the settings to use for a cluster.

Parameters:

  • cluster (String) –

    The name of the cluster to modify the settings for.

  • settings (ClusterSettings) –

    The setting to use by default for a cluster. This parameter is used to turn on CloudWatch Container Insights for a cluster. If this value is specified, it overrides the containerInsights value set with PutAccountSetting or PutAccountSettingDefault.

    Currently, if you delete an existing cluster that does not have Container Insights turned on, and then create a new cluster with the same name with Container Insights tuned on, Container Insights will not actually be turned on. If you want to preserve the same name for your existing cluster and turn on Container Insights, you must wait 7 days before you can re-create it.

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.

  • UpdateInProgressException –

    There's already a current Amazon ECS container agent update in progress on the container instance that's specified. If the container agent becomes disconnected while it's in a transitional stage, such as PENDING or STAGING, the update process can get stuck in that state. However, when the agent reconnects, it resumes where it stopped previously.

  • UnknownServiceError –

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

Examples:

To update a cluster's settings This example enables CloudWatch Container Insights for the default cluster.

>>> client.update_cluster_settings(cluster='default', settings=[{'name': 'containerInsights', 'value': 'enabled'}])
Source code in docs_src/capo_ecs/_services/ecs.py
def update_cluster_settings(
    self,
    cluster: "capo_ecs.types.string.String",
    settings: "capo_ecs.types.cluster_settings.ClusterSettings",
    *,
    config_overrides: Optional[ECSClientConfig] = None,
) -> (
    "capo_ecs.types.update_cluster_settings_response.UpdateClusterSettingsResponse"
):
    """<p>Modifies the settings to use for a cluster.</p>

    Args:
        cluster: <p>The name of the cluster to modify the settings for.</p>
        settings: <p>The setting to use by default for a cluster. This parameter is used to turn on CloudWatch Container Insights for a cluster. If this value is specified, it overrides the <code>containerInsights</code> value set with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PutAccountSetting.html">PutAccountSetting</a> or <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PutAccountSettingDefault.html">PutAccountSettingDefault</a>.</p> <important> <p>Currently, if you delete an existing cluster that does not have Container Insights turned on, and then create a new cluster with the same name with Container Insights tuned on, Container Insights will not actually be turned on. If you want to preserve the same name for your existing cluster and turn on Container Insights, you must wait 7 days before you can re-create it.</p> </important>

    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.update_in_progress_exception.UpdateInProgressException: <p>There's already a current Amazon ECS container agent update in progress on the container instance that's specified. If the container agent becomes disconnected while it's in a transitional stage, such as <code>PENDING</code> or <code>STAGING</code>, the update process can get stuck in that state. However, when the agent reconnects, it resumes where it stopped previously.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To update a cluster's settings
        This example enables CloudWatch Container Insights for the default cluster.

        >>> client.update_cluster_settings(cluster='default', settings=[{'name': 'containerInsights', 'value': 'enabled'}])
    """

    def _handler(
        req: "OperationRequest[capo_ecs.types.update_cluster_settings_request.UpdateClusterSettingsRequest]",
    ) -> OperationResponse[
        "capo_ecs.types.update_cluster_settings_response.UpdateClusterSettingsResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.update_cluster_settings

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateClusterSettings")
    )
    input_: capo_ecs.types.update_cluster_settings_request.UpdateClusterSettingsRequest = {
        "cluster": cluster,
        "settings": settings,
    }

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