Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporarily Stop/Deactivate ECS Fargate cluster or service

This is almost the same question as this one, but for Fargate.

I can't find any way to just stop the cluster or the Fargate service temporarily without having to delete it or changing its task definition.

Tried to stop each task individually but as expected, Fargate provisions a new task right after.

Seems there no option in the AWS console yet - maybe a CLI option exists?

like image 373
Marco Medrano Avatar asked Jun 09 '19 17:06

Marco Medrano


People also ask

How do you pause an ECS cluster?

Stopping a taskIn the ECS Cluster view, click Tasks on the left. Make sure Desired Task Status is set to Running . Choose the individual tasks to stop and then click Stop or click Stop All to select and stop all running tasks.

How do I temporarily disable ECS?

From EC2 Management ConsoleClick Auto Scaling Groups from the left menu. Select the group from the list. Click edit on the details tab. Set desired property to '0'.

How do you stop fargate ECS?

Fargate does not allow you to stop the cluster because there are no underlying EC2 instances that you control to stop. Resources are provisioned in a "serverless" way so you don't have to deal with the underlying resources.


2 Answers

Fargate does not allow you to stop the cluster because there are no underlying EC2 instances that you control to stop. Resources are provisioned in a "serverless" way so you don't have to deal with the underlying resources.

You need to stop the individual tasks but, like you reported, you may encounter that they are replaced after you stop the running tasks that are part of a service. To ensure this doesn't happen update your services to have a "Number of tasks" set to 0. This will keep your service definition up so you don't have to delete them but it will allow you to remove any running tasks.

Hope that helps!

like image 129
JD D Avatar answered Oct 19 '22 20:10

JD D


Found a command in the ecs-cli that does exactly what @jd-d described:

ecs-cli compose --project-name name service down --cluster-config cluster --cluster cluster

Stops the running tasks that belong to the service created with the compose project. This command updates the desired count of the service to 0.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-service-stop.html

It does work! but unfortunately I think it is not a complete answer as seems it only works when using ecs-cli and to manage docker compose.

like image 31
Marco Medrano Avatar answered Oct 19 '22 22:10

Marco Medrano