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

ECS capacity provider resource forces new resource when changing target_capacity #19542

Closed
ghost opened this issue May 26, 2021 · 3 comments
Closed
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ecs Issues and PRs that pertain to the ecs service.

Comments

@ghost
Copy link

ghost commented May 26, 2021

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform AWS Provider Version

Terraform v0.14.10
+ provider registry.terraform.io/hashicorp/aws v3.42.0

Affected Resource(s)

  • aws_ecs_capacity_provider

Terraform Configuration Files

resource "aws_ecs_capacity_provider" "pool_capacity" {
  name     = "general-ecs-pool"

  auto_scaling_group_provider {
    auto_scaling_group_arn         = aws_autoscaling_group.ecs_pool.arn
    managed_termination_protection = "ENABLED"

    managed_scaling {
      maximum_scaling_step_size = 10
      minimum_scaling_step_size = 1
      status                    = "ENABLED"
      instance_warmup_period    = 60
      target_capacity           = 75
    }
  }
  tags = { Name = "general-ecs-pool" }
}

Expected Behavior

The AWS provider should update in place the target_capacity for an existing capacity provider.

Actual Behavior

The provider forces a new resource and attempts to delete and re-create the existing capacity provider. When applying this change, the AWS provider will timeout and fail if you are running tasks on any instance managed by the capacity provider. The error it returns after failing and timing out is:

Error: error waiting for ECS Capacity Provider ([redacted_capacity_provider_arn]) to delete: timeout while waiting for state to become 'INACTIVE' (last state: 'ACTIVE', timeout: 20m0s)

Below is an example plan output:

  # module.fleet-ecs.aws_ecs_capacity_provider.pool_capacity must be replaced
-/+ resource "aws_ecs_capacity_provider" "pool_capacity" {
      ~ arn      = "[redacted_capacity_provider_arn]" -> (known after apply)
      ~ id       = "[redacted_capacity_provider_arn]" -> (known after apply)
        name     = "general-ecs-pool"
        tags     = {
            "Name" = "general-ecs-pool"
        }
        # (1 unchanged attribute hidden)

      ~ auto_scaling_group_provider {
            # (2 unchanged attributes hidden)

          ~ managed_scaling {
              ~ target_capacity           = 75 -> 100 # forces replacement
                # (4 unchanged attributes hidden)
            }
        }
    }

Steps to Reproduce

  1. using the above code example and an associated ASG, plan and apply to create a capacity provider with a specific target_capacity.
  2. change the target_capacity.
  3. terraform plan. It will show you that it intends to re-create the capacity provider by forcing a new resource.
  4. terraform apply. It will attempt to delete and re-create the existing capacity provider. This will timeout and fail if you are running instances on any instance in the capacity provider.

Important Factoids

It looks like the go AWS SDK has already implemented UpdateCapacityProvider as of v1.35.34 so it should be possible to include in the AWS provider for terraform already.

@ghost ghost added the service/ecs Issues and PRs that pertain to the ecs service. label May 26, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 26, 2021
@ewbankkit ewbankkit added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels May 27, 2021
@ewbankkit
Copy link
Contributor

@rue-nsilverman Thanks for raising this issue.
It has already been noticed in #16943. I'm going to close this one as a duplicate so that we can concentrate discussion in the linked issue.
Please add any additional comments there.

@ghost
Copy link
Author

ghost commented May 27, 2021

@ewbankkit Ah, perfect, I could not find an existing issue with the search terms I was using, thanks!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

No branches or pull requests

1 participant