Open ahujarajesh opened 4 years ago
This issue gets reproduced even if I explicit dependency on aws_ecs_service using depends_on
Also, surprisingly terraform does not show in the plan or apply that appautoscaling policy is getting destroyed.
This issue is same as #5747 which is marked fixed in v 2.3.0 of the Terraform AWS provider. However this was tested on v2.23.0 and v2.24.0 and it fails on both. Is this possibly a regression?
@bflad, Can you help here?
I think issue #5747 (PR #7982) was just for the relationship between autoscaling policy and target. Your issue is between the target and the ECS service.
I ran into the same issue and was able to do a temporary workaround via using an empty interpolation of the unknown property id.
Just the reference of name
isn't enough since Terraform doesn't expect that property to change during a recreate for other reasons. The ECS service would get deleted, automatically deleting the autoscaling target. Terraform still thinks the autoscaling target is there so will not recreate. This will force terraform to:
resource "aws_appautoscaling_target" "service" {
service_namespace = "ecs"
resource_id = "service/${var.cluster_name}/${aws_ecs_service.service.name}${replace(aws_ecs_service.service.id, "/.*/", "")}"
scalable_dimension = "ecs:service:DesiredCount"
min_capacity = var.autoscaling_min_count
max_capacity = var.autoscaling_max_count
}
Hey @ahujarajesh š Thank you for taking the time to file this issue! Given that there's been a number of AWS provider releases since you initially filed it, and the workaround provided above, can you confirm whether you're still experiencing this behavior?
We just hit this issue with v3.71.0 of the AWS provider.
Can it be that AWS removes the resources in order to unblock destruction of the ECS service, and so the problem is invisible to Terraform until it runs again?
Hey @marksumm š Thanks for confirming you're still experiencing this. I've marked this as a bug so that we can look into it as soon as time allows.
We were also having this issue. @danieladams456 work around worked for us, but seems like it shouldn't be necessary. This issue has been open for almost four years.
Community Note
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Not Applicable
Panic Output
Not Applicable
Expected Behavior
If ECS Service gets destroyed and recreated then aws_appautoscaling_policy should also get created.
Actual Behavior
When ECS Service gets destroyed and recreated aws_appautoscaling_policy gets destroyed.
Steps to Reproduce
Create aws_ecs_task_definition, aws_ecs_service, aws_lb_target_group, aws_lb_listener_rule, aws_appautoscaling_target, aws_appautoscaling_policy
.Run terraform apply
Change anything in aws_ecs_service so it will trigger destroy and recreate of aws_ecs_service
Run terraform apply