stopTask

inline suspend fun EcsClient.stopTask(crossinline block: StopTaskRequest.Builder.() -> Unit): StopTaskResponse

Stops a running task. Any tags associated with the task will be deleted.

When you call StopTask on a task, the equivalent of docker stop is issued to the containers running in the task. This results in a SIGTERM value and a default 30-second timeout, after which the SIGKILL value is sent and the containers are forcibly stopped. If the container handles the SIGTERM value gracefully and exits within 30 seconds from receiving it, no SIGKILL value is sent.

For Windows containers, POSIX signals do not work and runtime stops the container by sending a CTRL_SHUTDOWN_EVENT. For more information, see Unable to react to graceful shutdown of (Windows) container #25982 on GitHub.

The default 30-second timeout can be configured on the Amazon ECS container agent with the ECS_CONTAINER_STOP_TIMEOUT variable. For more information, see Amazon ECS Container Agent Configuration in the Amazon Elastic Container Service Developer Guide.

Samples


fun main() { 
   //sampleStart 
   // This example stops a task with ID "1dc5c17a-422b-4dc4-b493-371970c6c4d6" in cluster "MyCluster".
val resp = ecsClient.stopTask {
    cluster = "MyCluster"
    task = "1dc5c17a-422b-4dc4-b493-371970c6c4d6"
    reason = "testing stop task."
} 
   //sampleEnd
}