Deletes the specified cluster. The cluster transitions to the INACTIVE state. Clusters with an INACTIVE status might remain discoverable in your account for a period of time. However, this behavior is subject to change in the future. We don't recommend that you rely on INACTIVE clusters persisting.
You must deregister all container instances from this cluster before you may delete it. You can list the container instances in a cluster with ListContainerInstances and deregister them with DeregisterContainerInstance.
Parameters:
-
cluster
(String)
–
The short name or full Amazon Resource Name (ARN) of the cluster to delete.
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.
-
ClusterContainsCapacityProviderException
–
The cluster contains one or more capacity providers that prevent the requested operation. This exception occurs when you try to delete a cluster that still has active capacity providers, including Amazon ECS Managed Instances capacity providers. You must first delete all capacity providers from the cluster before you can delete the cluster itself.
-
ClusterContainsContainerInstancesException
–
You can't delete a cluster that has registered container instances. First, deregister the container instances before you can delete the cluster. For more information, see DeregisterContainerInstance.
-
ClusterContainsServicesException
–
You can't delete a cluster that contains services. First, update the service to reduce its desired task count to 0, and then delete the service. For more information, see UpdateService and DeleteService.
-
ClusterContainsTasksException
–
You can't delete a cluster that has active tasks.
-
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 delete an empty cluster
This example deletes an empty cluster in your default region.
>>> client.delete_cluster(cluster='my_cluster')
Source code in docs_src/capo_ecs/_services/ecs.py
| def delete_cluster(
self,
cluster: "capo_ecs.types.string.String",
*,
config_overrides: Optional[ECSClientConfig] = None,
) -> "capo_ecs.types.delete_cluster_response.DeleteClusterResponse":
"""<p>Deletes the specified cluster. The cluster transitions to the <code>INACTIVE</code> state. Clusters with an <code>INACTIVE</code> status might remain discoverable in your account for a period of time. However, this behavior is subject to change in the future. We don't recommend that you rely on <code>INACTIVE</code> clusters persisting.</p> <p>You must deregister all container instances from this cluster before you may delete it. You can list the container instances in a cluster with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListContainerInstances.html">ListContainerInstances</a> and deregister them with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeregisterContainerInstance.html">DeregisterContainerInstance</a>.</p>
Args:
cluster: <p>The short name or full Amazon Resource Name (ARN) of the cluster to delete.</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_contains_capacity_provider_exception.ClusterContainsCapacityProviderException: <p>The cluster contains one or more capacity providers that prevent the requested operation. This exception occurs when you try to delete a cluster that still has active capacity providers, including Amazon ECS Managed Instances capacity providers. You must first delete all capacity providers from the cluster before you can delete the cluster itself.</p>
capo_ecs.errors.cluster_contains_container_instances_exception.ClusterContainsContainerInstancesException: <p>You can't delete a cluster that has registered container instances. First, deregister the container instances before you can delete the cluster. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeregisterContainerInstance.html">DeregisterContainerInstance</a>.</p>
capo_ecs.errors.cluster_contains_services_exception.ClusterContainsServicesException: <p>You can't delete a cluster that contains services. First, update the service to reduce its desired task count to 0, and then delete the service. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html">UpdateService</a> and <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeleteService.html">DeleteService</a>.</p>
capo_ecs.errors.cluster_contains_tasks_exception.ClusterContainsTasksException: <p>You can't delete a cluster that has active tasks.</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 delete an empty cluster
This example deletes an empty cluster in your default region.
>>> client.delete_cluster(cluster='my_cluster')
"""
def _handler(
req: "OperationRequest[capo_ecs.types.delete_cluster_request.DeleteClusterRequest]",
) -> OperationResponse[
"capo_ecs.types.delete_cluster_response.DeleteClusterResponse"
]:
import capo_ecs._operations.amazon_ec2_container_service_v20141113.delete_cluster
output, http_response = (
capo_ecs._operations.amazon_ec2_container_service_v20141113.delete_cluster.delete_cluster(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DeleteCluster")
)
input_: capo_ecs.types.delete_cluster_request.DeleteClusterRequest = {
"cluster": cluster
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|