Open josiegd-verrency opened 2 years ago
Observing the same thing. with:
Terraform v1.1.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.74.0
I can successfully switch from launchType
to capacityProviders
using AWS CLI:
aws ecs update-service --cluster dev --service hello-world \
--capacity-provider-strategy=capacityProvider=FARGATE,base=0,weight=100 \
--force-new-deployment
but if I try doing this with terraform, I get service recreation warning.
We were just about to introduce FARGATE_SPOT in our services, and now we need to push these plans back a bit, because we cannot possible downtime like this on our production environments.
Looks like the bug is in this line: https://github.com/hashicorp/terraform-provider-aws/blob/41fe8a96949b8096e01ab6edbbb0026092e5bc6d/internal/service/ecs/service.go#L401
The (ol == 0 && nl > 0)
part of the if statement condition is unnecessary - AWS is capable of applying change from launchType
to capacityProviders
. The only additional requirement is to stop passing explicit launchType = "FARGATE"
from terraform.
Also, the whole thing requires force_new_deployment
flag to be set to true
, otherwise terraform will recreate the service on any change to capacity providers: https://github.com/hashicorp/terraform-provider-aws/blob/41fe8a96949b8096e01ab6edbbb0026092e5bc6d/internal/service/ecs/service.go#L389-L394
I'm not entirely sure what kind of "backward compatibility" this commend mentions, but if that's something that terraform offered, and now would not, I think that the previous behaviour was a bug, and persisting it like this is not the greatest idea. In general, you don't want your ECS Service to get recreated when changes are applied, because that causes downtime.
I see this behavior also in one of the latest versions. Is it possible to fix it in the provider?
$: terraform version
Terraform v1.5.4
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.13.1
+ provider registry.terraform.io/hashicorp/http v3.4.0
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/hashicorp/tls v4.0.4
I'm wondering if it's worth adding a new option, something like the below. Pretty much the same as the code block for force_new_deployment but limited to just allowing capacity provider updates without destroying the service if there are no other destructive changes
if v := d.Get("non_destructive_capacity_provider_update").(bool); !v { return capacityProviderStrategyForceNew(d) }
Hi all,
I am interested in submiting a fix for this issue as it is impacting our internal usage also.
Is the community in agreement what are the latest requirements on how the update should work, as in the comments a couple of ideas are mentioned?
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.12.31
Affected Resource(s)
Expected Behavior
The ECS service should have been updated/modified in place.
Actual Behavior
The ECS service was scheduled for replacement, which would cause an outage.
Plan output:
Steps to Reproduce
aws_ecs_service
without a capacity provider specified, launch_type = "FARGATE"aws_ecs_service
to specify acapacity_provider_strategy
as follows:Important Factoids
References
AWS docs: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html
11351