How to restart an AWS ECS service

Josh Sherman
2 min read
Servers / Serverless AWS DevOps

Docker containers are easily one of my favorite pieces of new technology of the last decade. They’ve immensely simplified how I work locally, no more virtual machines, no more trying to keep my local development environment and production servers in parity, and no need for command-line sloths like nvm.

They’ve also changed how we deploy applications to production, going as far as eliminating the need to run dedicated servers and simplifying the hell out of clustering applications.

As far as containers have taken us over the years, containers do need to be restarted between deployments from time to time. Memory leaks, gremlins in our code, and such, contribute to this need.

At Mailshake, we use AWS Elastic Container Service (ECS) by way of AWS Fargate for many of our microservices, and one such service has been experiencing a ghost in the machine, if you will.

By the way, WE’RE HIRING a backend engineer to join the Mailshake engineering team to help us improve our sales outreach product as well as bust some of them ghosts ;)

With that all being said, executing an entire CI/CD pipeline to redeploy an ECS container tends to be over kill. Running linting, tests, and then finally deploying is time consuming and unnecessary when all you need to do is get things redeployed from an already tested and deployed image.

Fortunately, we don’t have to go through the usual CI/CD pipeline, and can simply update the service, and tell it to force a new deployment, as nothing will actually be changing.

This can be done via the AWS Console (direct links omitted as they are region specific and I don’t want to add any unnecessary confusion):

  1. Log into the AWS Management Console.
  2. Go to Elastic Container Service.
  3. Go to Clusters.
  4. Click on the cluster that your service is in.
  5. Click on the service you’d like to restart.
  6. Click Update.
  7. Check Force new deployment about half way down the page.
  8. Click Skip to review.
  9. Click Update service.
  10. Wait patiently as your service restarts!

No much to it, but there are quite a few steps involved to make it happen. If you’re a fan of the AWS CLI (as I am), you can accomplish everything outlined above with this command:

aws ecs update-service --cluster :clusterName --service :serviceName --force-new-deployment

You may still want to navigate out to ECS to monitor the status of the deployment, that’s up to you.

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles