Fix issue preventing replacing when ASG capacity provider is associated with a cluster #39720
+50
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request resolves issue #14393.
The aws_ecs_cluster_capacity_providers resource depends on the aws_ecs_capacity_provider. Currently, when the aws_ecs_capacity_provider is force replaced due to a rename or other modification, the aws_ecs_cluster_capacity_providers is updated in-place. However, in AWS, deleting a capacity_provider via API fails if it is still associated with a cluster (which corresponds to the cluster_capacity_provider resource in Terraform). This is the root cause of issue #14393. What this means is that the aws_ecs_cluster_capacity_providers must be deleted before the aws_ecs_capacity_provider can be deleted.
The solution is to enable force new on the capacity_providers argument within the aws_ecs_cluster_capacity_providers. This ensures that when a aws_ecs_capacity_provider is force replaced, the aws_ecs_cluster_capacity_providers is also force replaced, allowing the association with the cluster to be removed before the aws_ecs_capacity_provider is deleted. This resolves the issue.
Relations
Closes #14393
References
Output from Acceptance Testing
The test case TestAccECSClusterCapacityProviders_destroy is failing, but as reported in issue #38408, this is a failing test even in the latest main branch, and is not caused by this pull request.