Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ECS service to do a force redeploy?

Tags:

terraform

I have a docker image in ECR which I update frequently. I would like ECS to do a force deploy in order to get the service to pick up the latest version of the image.

The service is checked into terraform so I would rather have terraform do the heavy lifting for me instead of writing a script to force redeploy.

How can I leverage terraform to force ECS service redeploy?

like image 788
wonton Avatar asked Oct 27 '25 05:10

wonton


1 Answers

What I found that works best is to taint the task definition.

terraform taint -module=mysandbox aws_ecs_task_definition.sandbox
terraform apply

Terraform will perform the following actions:

  ~ module.mysandbox.aws_ecs_service.sandbox
      task_definition:       "some-old-arn" => "${aws_ecs_task_definition.sandbox.arn}"

-/+ module.mysandbox.aws_ecs_task_definition.sandbox (tainted) (new resource required)
      ...
      revision:              "3" => <computed>

As you can see the task definition in the ecs_service is updated to the new task definition which has an incremented revision number.

like image 185
wonton Avatar answered Oct 29 '25 21:10

wonton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!