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

Migrating to ordered_placement_strategy forces a new resource #4557

Closed
icco opened this issue May 16, 2018 · 11 comments
Closed

Migrating to ordered_placement_strategy forces a new resource #4557

icco opened this issue May 16, 2018 · 11 comments
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service.
Milestone

Comments

@icco
Copy link

icco commented May 16, 2018

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

$ terraform -v
Terraform v0.11.7
+ provider.aws v1.18.0
+ provider.template v1.0.0

Affected Resource(s)

  • aws_ecs_service

Terraform Configuration Files

resource "aws_ecs_service" "service" {
  name = "${var.service_name}"

  cluster         = "${var.cluster_id}"
  task_definition = "${coalesce(var.task_def, var.service_name)}"
  desired_count   = "${var.service_desired_count}"

  iam_role = "${var.service_iam_role_name}"

  deployment_maximum_percent         = "${var.deployment_maximum_percent}"
  deployment_minimum_healthy_percent = "${var.deployment_minimum_healthy_percent}"

  # once setup, the task definition is updated via circleci
  lifecycle {
    ignore_changes = ["task_definition"]
  }

  depends_on = [
    "aws_alb_listener.service",
  ]

  ordered_placement_strategy {
    field = "attribute:ecs.availability-zone"
    type  = "spread"
  }

  ordered_placement_strategy {
    field = "instanceId"
    type  = "spread"
  }

  load_balancer {
    target_group_arn = "${aws_alb_target_group.service.id}"
    container_name   = "${var.service_name}"
    container_port   = "${var.service_port}"
  }
}

Debug Output

Panic Output

Expected Behavior

Changing placement_strategy to ordered_placement_strategy would cause no diff in plan.

Actual Behavior

Every service we have using this module needs to be recreated.

Steps to Reproduce

  1. Create a service with placement_strategy
  2. terraform apply
  3. Modify service by changing placement_strategy to ordered_placement_strategy
  4. terraform plan

Important Factoids

References

@bflad bflad added bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service. labels May 18, 2018
@bflad
Copy link
Contributor

bflad commented May 18, 2018

Hi @icco 👋 sorry you are running into trouble here and thanks for reporting it. Can you share the terraform plan output? Is it showing something like the following?

ordered_placement_strategy.#: "0" => "1" (forces new resource)
placement_strategy.#:         "1" => "0" (forces new resource)

We might need to customize the difference when converting.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label May 18, 2018
@icco
Copy link
Author

icco commented May 18, 2018 via email

@icco
Copy link
Author

icco commented May 18, 2018

An example service that would be affected:

-/+ module.yahtzee.aws_ecs_service.service (new resource required)
      id:                                        "arn:aws:ecs:us-east-1:...:service/yahtzee" => <computed> (forces new resource)
      cluster:                                   "arn:aws:ecs:us-east-1:...:cluster/platform-unified-cluster" => "arn:aws:ecs:us-east-1:...:cluster/platform-unified-cluster"
      deployment_maximum_percent:                "200" => "200"
      deployment_minimum_healthy_percent:        "50" => "50"
      desired_count:                             "1" => "1"
      iam_role:                                  "ecs_service" => "ecs_service"
      launch_type:                               "EC2" => "EC2"
      load_balancer.#:                           "1" => "1"
      load_balancer.214228493.container_name:    "yahtzee" => "yahtzee"
      load_balancer.214228493.container_port:    "8080" => "8080"
      load_balancer.214228493.elb_name:          "" => ""
      load_balancer.214228493.target_group_arn:  "arn:aws:elasticloadbalancing:us-east-1:...:targetgroup/yahtzee/053b1f67a2e1b589" => "arn:aws:elasticloadbalancing:us-east-1:...:targetgroup/yahtzee/053b1f67a2e1b589"
      name:                                      "yahtzee" => "yahtzee"
      ordered_placement_strategy.#:              "" => "2" (forces new resource)
      ordered_placement_strategy.0.field:        "" => "attribute:ecs.availability-zone" (forces new resource)
      ordered_placement_strategy.0.type:         "" => "spread" (forces new resource)
      ordered_placement_strategy.1.field:        "" => "instanceId" (forces new resource)
      ordered_placement_strategy.1.type:         "" => "spread" (forces new resource)
      placement_strategy.#:                      "2" => "0" (forces new resource)
      placement_strategy.2750134989.field:       "instanceId" => "" (forces new resource)
      placement_strategy.2750134989.type:        "spread" => "" (forces new resource)
      placement_strategy.3619322362.field:       "attribute:ecs.availability-zone" => "" (forces new resource)
      placement_strategy.3619322362.type:        "spread" => "" (forces new resource)
      task_definition:                           "yahtzee:26" => "yahtzee"

@icco
Copy link
Author

icco commented Jun 21, 2018

@bflad what's the possibility of this getting fixed and/or the timeline for placement_strategy going away? I'm worried about us having to pin our version of aws in case it goes away without a fix being in place.

@ihakimi
Copy link

ihakimi commented Jul 4, 2018

I am having this issue too, when upgrade aws provider and using placement_strategy.
This cause downtime, any update when its going to be fixed?

@maxblaze
Copy link

We also have this issue. Originally I thought it was because the placement order changed, but we kept the order the same and it still forced a new service resource.

@bflad
Copy link
Contributor

bflad commented Feb 26, 2019

Hi Folks 👋 Apologies that this was never addressed properly in the version 1.X releases after the change and before version 2.0.0. 😖 We are still working on proper documentation for the process of deprecating attributes, which looks like it will require some additional notes surrounding ForceNew attributes.

Luckily, when upgrading your environments to version 2.0.0 (releasing later this week) or later, the aws_ecs_service resource will be always refreshing ordered_placement_strategy in the Terraform state, so you should be able to just change placement_strategy to ordered_placement_strategy in your configurations without issue as part of the upgrade. If all else fails, terraform state rm and terraform import can be used to workaround this problematic change as well.

Again, sorry for the hassle with this deprecation. We can certainly do better here and will continue to try and prevent these sort of upgrade problems in the future for the Terraform AWS Provider and other Terraform Providers as well.

@bflad bflad closed this as completed Feb 26, 2019
@maxblaze
Copy link

maxblaze commented Feb 27, 2019

@bflad I just tried this with 2.0.0 and it's still trying to recreate the service. This is a huge problem for us:

      ordered_placement_strategy.#:                           "2" => "2"
      ordered_placement_strategy.0.field:                     "memory" => "memory"
      ordered_placement_strategy.0.type:                      "binpack" => "binpack"
      ordered_placement_strategy.1.field:                     "attribute:ecs.availability-zone" => "attribute:ecs.availability-zone"
      ordered_placement_strategy.1.type:                      "spread" => "spread"
      placement_strategy.#:                                   "2" => "0" (forces new resource)
      placement_strategy.2224589570.field:                    "memory" => "" (forces new resource)
      placement_strategy.2224589570.type:                     "binpack" => "" (forces new resource)
      placement_strategy.3619322362.field:                    "attribute:ecs.availability-zone" => "" (forces new resource)
      placement_strategy.3619322362.type:                     "spread" => "" (forces new resource)

@venkata6
Copy link

venkata6 commented Mar 1, 2019

@bflad this is happening for us too in the latest version 2.0.0

@bflad
Copy link
Contributor

bflad commented Mar 1, 2019

@maxblaze @venkata6 I have created #7787 to triage this before our next release.

@ghost
Copy link

ghost commented Mar 31, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

No branches or pull requests

5 participants