Search code examples
amazon-web-servicesamazon-ec2amazon-ecs

AWS ECS run latest task definition


I am trying to have run the lastest task definition image built from GitHub deployment (CD). Seems like on AWS it creates a task definition for example "task-api:1", "task-api:2", on was my cluster is still running task-api: 1 even though there is the latest task as a new image has been built. So far I have to manually stop the old one and start a new one . How can I have it automated?


Solution

  • You must wrap your tasks in a service and use rolling updates for automated deployments.

    When the rolling update (ECS) deployment type is used for your service, when a new service deployment is started the Amazon ECS service scheduler replaces the currently running tasks with new tasks.

    Read: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html

    This is DevOps, so you need a CI/CD pipeline that will do the rolling updates for you. Look at CodeBuild, CodeDeploy and CodePipeline (and CodeCommit if you integrate your code repository in AWS with your CI/CD)

    Read: https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html

    This is a complex topic, but it pays off in the end.