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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With