Skip to content

ECS  >  Operations  >  deregister_container_instance

deregister_container_instance

Operation

deregister_container_instance async

deregister_container_instance(input: DeregisterContainerInstanceInput, plugins: list[Plugin] | None = None) -> DeregisterContainerInstanceOutput

Deregisters an Amazon ECS container instance from the specified cluster. This instance is no longer available to run tasks.

If you intend to use the container instance for some other purpose after deregistration, we recommend that you stop all of the tasks running on the container instance before deregistration. That prevents any orphaned tasks from consuming resources.

Deregistering a container instance removes the instance from a cluster, but it doesn't terminate the EC2 instance. If you are finished using the instance, be sure to terminate it in the Amazon EC2 console to stop billing.

Note

If you terminate a running container instance, Amazon ECS automatically deregisters the instance from your cluster (stopped container instances or instances with disconnected agents aren't automatically deregistered when terminated).

Parameters:

Name Type Description Default
input DeregisterContainerInstanceInput

An instance of DeregisterContainerInstanceInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
DeregisterContainerInstanceOutput

An instance of DeregisterContainerInstanceOutput.

Input

DeregisterContainerInstanceInput dataclass

Bases: _SerdeShape

Attributes

cluster class-attribute instance-attribute
cluster: str | None = ...

The short name or full Amazon Resource Name (ARN) of the cluster that hosts the container instance to deregister. If you do not specify a cluster, the default cluster is assumed.

container_instance class-attribute instance-attribute
container_instance: str | None = ...

The container instance ID or full ARN of the container instance to deregister. For more information about the ARN format, see Amazon Resource Name (ARN) in the Amazon ECS Developer Guide.

force class-attribute instance-attribute
force: bool | None = ...

Forces the container instance to be deregistered. If you have tasks running on the container instance when you deregister it with the force option, these tasks remain running until you terminate the instance or the tasks stop through some other means, but they're orphaned (no longer monitored or accounted for by Amazon ECS). If an orphaned task on your container instance is part of an Amazon ECS service, then the service scheduler starts another copy of that task, on a different container instance if possible.

Any containers in orphaned service tasks that are registered with a Classic Load Balancer or an Application Load Balancer target group are deregistered. They begin connection draining according to the settings on the load balancer or target group.

Output

DeregisterContainerInstanceOutput dataclass

Bases: _SerdeShape

Attributes

container_instance class-attribute instance-attribute
container_instance: ContainerInstance | None = ...

The container instance that was deregistered.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.