AWS

How to update AWS ECS service

To update a ECS service using script you can use the below command

Checkout my YouTube video on this blog.

Parameters required

  • Cluster Name
  • Service Name
aws ecs update-service --cluster ecsdeployment --service ecsdeployment-WebService-AP1WCLw9qhgn --force-new-deployment --region us-east-1

In some cases, this command didn’t update the service and if you need to run just one container for your service and you can have downtime then update your service as shown below :

Automation

You can easily automate this process from your pipeline. Create a shell script and run these commands

  • You need to use the login command to push the images in ECR
  • Build, tag and publish
  • Update the service
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com
docker build -t XXXXX -f Dockerfile.nginx . --no-cache
docker tag XXXXX:latest XXXXXXX.dkr.ecr.us-east-1.amazonaws.com/XXXXX:latest
sudo docker push XXXXXX.dkr.ecr.us-east-1.amazonaws.com/XXXX:latest
aws ecs update-service --cluster ecsdeployment --service ecsdeployment-WebService-AP1WCLw9qhgn --force-new-deployment --region us-east-1
Please follow and like us: