Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The aws_ecs_service doesn't wait for a new computed aws_ecs_task_definition #2694

Closed
killercentury opened this issue Jul 11, 2015 · 15 comments · Fixed by #3924
Closed

The aws_ecs_service doesn't wait for a new computed aws_ecs_task_definition #2694

killercentury opened this issue Jul 11, 2015 · 15 comments · Fixed by #3924

Comments

@killercentury
Copy link

I found that the aws_ecs_service doesn't wait for the new computed aws_ecs_task_definition. It just uses the old aws_ecs_task_definition at the first time I run plan and apply. When I run plan and apply again, it will pick up the new aws_ecs_task_definition.

Here is my sample config:

resource "aws_ecs_task_definition" "terraform_ecs_demo" {
  family = "terraform-ecs-demo"
  container_definitions = "${file("ecs-container-definitions.json")}"
}

resource "aws_ecs_service" "terraform_ecs_demo" {
  name = "terraform-ecs-demo"
  cluster = "${aws_ecs_cluster.default.id}"
  task_definition = "${aws_ecs_task_definition.terraform_ecs_demo.arn}"
  desired_count = 1
}

I also tried adding depends_on = ["aws_ecs_task_definition.terraform_ecs_demo"] to the service, but same result.

@roosmaa
Copy link

roosmaa commented Sep 29, 2015

I'm also getting this. Could this be that terraform aws_ecs_task_definition doesn't know that when updating the definition it should also bump the revision number in it's arn, thus aws_ecs_service can't pick up the change?

@CpuID
Copy link
Contributor

CpuID commented Sep 30, 2015

yep, noticing the same here, 0.6.3. have been manually updating the task def on the service so far, but if another apply does the job makes sense.

@dhumphreys
Copy link

I am also experiencing this. Any updates?

@brikis98
Copy link
Contributor

I'm having the same issue here on 0.6.4. I update the aws_ecs_task_definition, run terraform apply, and the new revision shows up in ECS, but the service is not updated. If I run terraform apply again, the service is updated, and the new revision gets deployed. I'll poke around the code to see if I can spot the bug and submit a PR, but I'm new to Go, so pointers are welcome.

@catsby catsby added the waiting-response An issue/pull request is waiting for a response from the community label Nov 5, 2015
@catsby
Copy link
Contributor

catsby commented Nov 5, 2015

When you update the task definition and plan, does a change show up in the aws_ecs_service?

I would suspect not. The task definition's ARN isn't changing, is it? Does someone have a valid container_definitions file I can use?

@CpuID
Copy link
Contributor

CpuID commented Nov 5, 2015

@catsby no, not in this case. plan and apply yield the same result most of the time (just a task def change, without a service bump for the task version)

example of an aws_ecs_task_definition (including an inline container_definitions entry):

resource "aws_ecs_task_definition" "nginx" {
  family = "nginx"
  container_definitions = <<DEF
[
  {
    "name": "nginx",
    "image": "nginx:1.9.0",
    "cpu": 60, 
    "memory": 512,
    "essential": true,
    "environment": [
      {   
        "name": "SERVICE_NAME",
        "value": "nginx"
      }
    ],  
    "portMappings": [
      {   
        "containerPort": 80,
        "hostPort": 80
      }   
    ]   
  }
]
DEF
}

@listenrightmeow
Copy link

👍

@sunilvigneshr
Copy link

Experiencing this. Any Updates?

@buzzedword
Copy link

Also seeing this. 👍

@radeksimko
Copy link
Member

Reproduced, I think that marking all fields in aws_ecs_task_definition as ForceNew: true would probably fix this.

After all, we're effectively creating a new resource with a new ID anyway, so it won't make much difference IMO.
I will have a look into it.

@radeksimko
Copy link
Member

btw. I think the reason why aws_ecs_service doesn't get updated in the same run is because it has no idea whether ARN of the referenced aws_ecs_task_definition will be re-computed during plan. It is afaik only planned for re-computation when the whole resource gets re-created.

When re-computation actually happens - during apply, it's too late and terraform is just executing expected plan which won't change at that point.

@catsby Maybe there should be a way to trigger "recomputation" of Computed fields under certain conditions, what do you think?

@radeksimko
Copy link
Member

See #3924 which is fixing this (verified by a simple acceptance test included in the PR).

@radeksimko radeksimko removed the waiting-response An issue/pull request is waiting for a response from the community label Nov 14, 2015
@jbergknoff
Copy link

Should that fix be in 0.6.8? I just upgraded but still experience the issue: the task definition updates but the service depending on that task definition does not update. I need to terraform apply a second time to make the service update.

@radeksimko
Copy link
Member

@jbergknoff This should be fixed in 0.6.8. I am personally using both ecs_service & ecs_task_definition and it works fine for me.

If you're still experiencing any issues, report it as a new issue please. Ideally include the terraform code used (minus any secrets), so we can reproduce it and fix it.

@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.