Answer the question
In order to leave comments, you need to log in
How to automatically restart a task in ECS when pushing a new image?
There is a pipeline that pushes a new docker image to Amazon ECR.
There is a cluster that uses the last launched image.
For the changes from the new image to take effect, you need to restart this task in ECS.
How can this be automated?
Answer the question
In order to leave comments, you need to log in
Using the latest image is a bad practice.
As akelsey said , you need to update the Task Definition, and then nothing needs to be restarted.
I use aws-actions/amazon-ecs-render-task-definition
and
aws-actions/amazon-ecs-deploy-task-definition
for this in Github Actions
The best option with a configured service (desired tasks 1) is to push the image by assigning a version number, for example, a build number, and update the Task Defintion, then ECS will make the current image INACTIVE, initializing the second one in parallel (smoothly remove the old one from the service when the new one becomes active) .
If the proposed option is not an option, stop the task in the pipeline and run aws cli.
Hello, use EventBridge (formerly cloudwatch events) - https://docs.aws.amazon.com/codepipeline/latest/us... which will not call codepipeline (as in the example) when pushing a new image to ECR, but for example Lambda function that will update the ECS task of
luck, Vadim
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question