-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
resource/aws_ecs_service: Ensure placement_strategy removal in version 2.0.0 does not force recreation #7790
Conversation
…n 2.0.0 does not force recreation References: * #7787 Verified outside the acceptance testing framework as this type of testing is not well supported nor easy to implement, especially for a one-time fix. Theoretically, this can also be prevented with a resource state migration, but that also seems heavy handed for a one-time fix and the extraneous information left in the state should not hurt anything. Lessons learned here will be added to the Terraform Provider development documentation. Given this version 1.6.0 configuration: ```hcl provider "aws" { region = "us-east-2" version = "1.6.0" } resource "aws_ecs_cluster" "test" { name = "bflad-testing" } resource "aws_ecs_task_definition" "test" { family = "test" container_definitions = <<DEFINITION [ { "cpu": 128, "essential": true, "image": "busybox:latest", "memory": 128, "name": "busybox" } ] DEFINITION } resource "aws_ecs_service" "test" { cluster = "${aws_ecs_cluster.test.id}" desired_count = 0 name = "bflad-testing" task_definition = "${aws_ecs_task_definition.test.arn}" placement_strategy { field = "memory" type = "binpack" } placement_strategy { field = "attribute:ecs.availability-zone" type = "spread" } } ``` And attempting to upgrade the configuration to version 2.0.0 like the below: ```hcl provider "aws" { region = "us-east-2" version = "2.0.0" } resource "aws_ecs_cluster" "test" { name = "bflad-testing" } resource "aws_ecs_task_definition" "test" { family = "test" container_definitions = <<DEFINITION [ { "cpu": 128, "essential": true, "image": "busybox:latest", "memory": 128, "name": "busybox" } ] DEFINITION } resource "aws_ecs_service" "test" { cluster = "${aws_ecs_cluster.test.id}" desired_count = 0 name = "bflad-testing" task_definition = "${aws_ecs_task_definition.test.arn}" ordered_placement_strategy { field = "memory" type = "binpack" } ordered_placement_strategy { field = "attribute:ecs.availability-zone" type = "spread" } } ``` Would yield the following: ```console $ terraform plan ... Terraform will perform the following actions: -/+ aws_ecs_service.test (new resource required) ... 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) ... Plan: 1 to add, 0 to change, 1 to destroy. ``` These changes here yield the expected no-operation change: ```console $ cp ~/go/bin/terraform-provider-aws .terraform/plugins/darwin_amd64/terraform-provider-aws_v2.0.0_x4; terraform init # Overwrite with locally built binary with this change ... $ terraform plan ... No changes. Infrastructure is up-to-date. ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
…te removal with Computed/ForceNew and resource soft removal with friendly error messages References: * hashicorp/terraform-provider-aws#7815 * hashicorp/terraform-provider-aws#7790
This has been released in version 2.1.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Closes #7787
Verified outside the acceptance testing framework as this type of testing is not well supported nor easy to implement for a one-time fix. Theoretically, this can also be prevented with a resource state migration, but that also seems heavy handed for a one-time fix and the extraneous information left in the state should not hurt anything. Lessons learned here will be added to the Terraform Provider development documentation.
Given this version 1.6.0 configuration:
And attempting to upgrade the configuration to version 2.0.0 like the below:
Would yield the following:
These changes here yield the expected no-operation change: