Skip to content

update_cluster

update_cluster(
    cluster: String,
    *,
    config_overrides: Optional[ECSClientConfig] = None,
    settings: Optional[ClusterSettings] = None,
    configuration: Optional[ClusterConfiguration] = None,
    service_connect_defaults: Optional[ClusterServiceConnectDefaultsRequest] = None,
) -> UpdateClusterResponse

Updates the cluster.

Parameters:

  • cluster (String) –

    The name of the cluster to modify the settings for.

  • settings (Optional[ClusterSettings], default: None ) –

    The cluster settings for your cluster.

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

    The execute command configuration for the cluster.

  • service_connect_defaults (Optional[ClusterServiceConnectDefaultsRequest], default: None ) –

    Use this parameter to set a default Service Connect namespace. After you set a default Service Connect namespace, any new services with Service Connect turned on that are created in the cluster are added as client services in the namespace. This setting only applies to new services that set the enabled parameter to true in the ServiceConnectConfiguration. You can set the namespace of each service individually in the ServiceConnectConfiguration to override this default parameter.

    Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide.

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.

  • NamespaceNotFoundException –

    The specified namespace wasn't found.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnknownServiceError –

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

Examples:

To update a cluster's observability settings. This example turns on enhanced containerInsights in an existing cluster.

>>> client.update_cluster(cluster='ECS-project-update-cluster', settings=[{'name': 'containerInsights', 'value': 'enhanced'}])
To update a cluster's Service Connect defaults.
This example sets a default Service Connect namespace.
>>> client.update_cluster(cluster='ECS-project-update-cluster', service_connect_defaults={'namespace': 'test'})
Source code in docs_src/capo_ecs/_services/ecs.py
def update_cluster(
    self,
    cluster: "capo_ecs.types.string.String",
    *,
    config_overrides: Optional[ECSClientConfig] = None,
    settings: Optional["capo_ecs.types.cluster_settings.ClusterSettings"] = None,
    configuration: Optional[
        "capo_ecs.types.cluster_configuration.ClusterConfiguration"
    ] = None,
    service_connect_defaults: Optional[
        "capo_ecs.types.cluster_service_connect_defaults_request.ClusterServiceConnectDefaultsRequest"
    ] = None,
) -> "capo_ecs.types.update_cluster_response.UpdateClusterResponse":
    """<p>Updates the cluster.</p>

    Args:
        cluster: <p>The name of the cluster to modify the settings for.</p>
        settings: <p>The cluster settings for your cluster.</p>
        configuration: <p>The execute command configuration for the cluster.</p>
        service_connect_defaults: <p>Use this parameter to set a default Service Connect namespace. After you set a default Service Connect namespace, any new services with Service Connect turned on that are created in the cluster are added as client services in the namespace. This setting only applies to new services that set the <code>enabled</code> parameter to <code>true</code> in the <code>ServiceConnectConfiguration</code>. You can set the namespace of each service individually in the <code>ServiceConnectConfiguration</code> to override this default parameter.</p> <p>Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect.html">Service Connect</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</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.namespace_not_found_exception.NamespaceNotFoundException: <p>The specified namespace wasn't found.</p>
        capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To update a cluster's observability settings.
        This example turns on enhanced containerInsights in an existing cluster.

        >>> client.update_cluster(cluster='ECS-project-update-cluster', settings=[{'name': 'containerInsights', 'value': 'enhanced'}])
        To update a cluster's Service Connect defaults.
        This example sets a default Service Connect namespace.

        >>> client.update_cluster(cluster='ECS-project-update-cluster', service_connect_defaults={'namespace': 'test'})
    """

    def _handler(
        req: "OperationRequest[capo_ecs.types.update_cluster_request.UpdateClusterRequest]",
    ) -> OperationResponse[
        "capo_ecs.types.update_cluster_response.UpdateClusterResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.update_cluster

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateCluster")
    )
    input_: capo_ecs.types.update_cluster_request.UpdateClusterRequest = {
        "cluster": cluster
    }
    if settings is not None:
        input_["settings"] = settings
    if configuration is not None:
        input_["configuration"] = configuration
    if service_connect_defaults is not None:
        input_["service_connect_defaults"] = service_connect_defaults

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