LoginSignup
1
0

More than 5 years have passed since last update.

Terraformでtask-definisionを消したらエラーがで続けた...

Last updated at Posted at 2017-10-17

task-definitionをコンソールから停止

tfファイルを更新してもtask-definitionが更新されないので試しに現状動いているものを停止してみた

error.sh
$ terraform apply
aws_ecs_service.registry: ServiceNotActiveException: Service was not ACTIVE.
    status code: 400, request id:*****

後に更新されない理由が判明したがエラーが消えてくれない

原因

ECSのtaskは停止しても削除されず、INACTIVE状態で残るためにtfstateファイルから同じものを見続けることが判明
一時的に参照するtask-definitionを動いてるものに指定 => apply => 元に戻す でも効果なし

ecs.tf
resource "aws_ecs_service" "service_redash_blt" {
  name = "${terraform.env}-****"
  cluster = "${aws_ecs_cluster.****.id}"
  task_definition = "${aws_ecs_task_definition.****.arn}"
  desired_count = 1
  deployment_minimum_healthy_percent = 50
  deployment_maximum_percent = 100
  iam_role = "${aws_iam_role.****.arn}"

  load_balancer {
    elb_name = "${aws_elb.****.name}"
    container_name = "nginx"
    container_port = 80
  }
}

解決策

結局task-definitionのfamily自体を変更
terraformで作ったものをコンソールからいじってはいけないと痛感...

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0