-1

I have setup CICD using Codepipeline and CodeBuild that deploy my application to ECS Fargate container. This is the setup for the frontend of my app. For the backend I have another same CICD. But this time, I want to deploy my backend to the same ECS Fargate container using Cloudformation. I know I have to update the task definition.

How I can update the already existed task definition that only create backend container of my app to the same task definition that we have used for frontend. And it should not affect the frontend container?

Is there any workaround for this?

1 Answers1

1

You can't do that. Task definitions are immutable. You can only create new reversion of a task definition and deploy the new reversion. You can't change existing reversion. From docs:

A task definition revision is a copy of the current task definition with the new parameter values replacing the existing ones. All parameters that you do not modify are in the new revision. To update a task definition, create a task definition revision. If the task definition is used in a service, you must update that service to use the updated task definition.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • So when I create a new revision in the task definition and create new container to it. Then our previous container definition is replaced or it will remain in the task definition revision? I want to create new container and also want to have the previous container in task definition. Is it possible? – Rehan Shakeel Dec 02 '22 at 06:39
  • @RehanShakeel Yes, the new revision is copy of the old one with the new changes. – Marcin Dec 02 '22 at 07:00
  • Is there any document to create a revision of task definition using Cloudformation? – Rehan Shakeel Dec 02 '22 at 07:03
  • It will be done automatically if you change your template. – Marcin Dec 02 '22 at 07:10
  • Hi Marcin, I have just created revision but it replaced my previous container – Rehan Shakeel Dec 02 '22 at 08:14
  • @RehanShakeel I don't understad what you are doing. You have to update your question with exact details of what you do it, how you change and update your tempalte, how to reproduce the issue and what do you want to achieve. – Marcin Dec 02 '22 at 08:18