0

I saw the post How to manage versions of docker image in AWS ECS? and didn’t get a good answer for the question. In case of updating container image version (for example , from alpine:1.0.0 to alpine 1.0.1) What is the best practice to update the container image in the task definition? I’m using only one container per task definition.

As far as I understand there are two alternatives:

  1. Create new revision of task definition
  2. Create new task definition that its name contains the version of the image.

The pros of the first option are that I’m creating only one task definition, but the cons are that in case that I want to create new revision only if the definition was changed, then I need to describe the task, get the image from the container list, and then compare the version with the new image version.

Regarding the second option, is that I can see exactly if I created there is a task definition that contains my image or not. The cons are that I will create new task definition for every image version.

In both options, how should I handle the deregister logic?

Probably I missed something so would appreciate your answer. Thanks!

LiorKesten
  • 23
  • 5

1 Answers1

0

I've only ever seen the first alternative (Create new revision of task definition) used. If you are using Infrastructure as Code, such as CloudFormation or Terraform, then all the cons you have listed for that are no longer present.

"In both options, how should I handle the deregister logic?"

Just update the ECS service to use the latest version of the task definition. ECS will then deploy a new task, migrate the traffic to that task, and shut down the old task. You don't need to do anything else at that point. There is no special logic you need to implement yourself to deregister anything.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • terraform is not for deployment of the new app version. take a look at https://medium.com/google-cloud/dont-deploy-applications-with-terraform-2f4508a45987. ECS falls short in scenario when docker image is your app version and task definition should only be updated to new image version – jjuraszek May 24 '23 at 09:15
  • @jjuraszek I'm sorry but I completely disagree with that. I've used Terraform to deploy ECS container updates on multiple projects without any issues at all. I really don't see where ECS or Terraform "falls short" for deployments, at least for simple projects. – Mark B May 24 '23 at 11:22
  • I respect your approach and I agree that it works for simple setup. My aim is that teraform is mainly infrastructure description with much lower change rate implied. On the other hand app code changes very often and should be deployed in much higher rate. Therefore teraform is not the best replacement for CD. Again, I see value in using only teraform. It's just not ideal – jjuraszek May 25 '23 at 13:03
  • I don't think anyone is saying Terraform is a replacement for CD. I'm just saying I have used Terraform in CD environments before with success. Saying you can deploy either by CD or by Terraform is a false dichotomy. – Mark B May 25 '23 at 13:08