I've tested this a couple of times. Attaching an NLB to the ASG using a target group and then removing it again, terraform does not remove it from AWS
v0.11.1
Please list the resources as a list, for example:
resource "aws_autoscaling_group" "controllers" {
name = "${var.cluster_name}-controllers"
launch_configuration = "${aws_launch_configuration.controllers.name}"
min_size = "${var.min_controllers}"
max_size = "${var.max_controllers}"
health_check_type = "EC2"
health_check_grace_period = 600
wait_for_capacity_timeout = "10m"
load_balancers = ["${aws_elb.apiserver_elb.name}"]
target_group_arns = ["${aws_lb_target_group.apiserver_lb_internal.arn}"]
vpc_zone_identifier = ["${aws_subnet.cluster_subnets.*.id}"]
enabled_metrics = ["GroupDesiredCapacity", "GroupInServiceInstances", "GroupStandbyInstances", "GroupTotalInstances"]
tag {
key = "KubernetesCluster"
value = "${var.cluster_name}"
propagate_at_launch = true
}
tag {
key = "Role"
value = "Controller"
propagate_at_launch = true
}
}
Terraform should have removed the target group from the ASG on AWS
The ASG remained attached to the ASG
Please list the steps required to reproduce the issue, for example:
terraform applytarget_group_arnsterraform apply - nothing to changeI can confirm that this is still a problem with AWS provider version 1.46.0
It's actually quite a dangerous bug if the target group it refers to no longer exists; It causes autoscaling to fail to replace instances as they are terminated. In my case, our test environment scales down at night and failed to scale back up in the morning. However, when autoscaling groups are used (as they are most commonly) for 24 hour high availability and self-healing, this self healing would fail to happen in the case of outage / spot price termination etc. This could happen months removed from the terraform change to the ASG.
Can confirm the problem. The same way, lifecycle.ignore_changes seems to not be replicated either.
Terraform v0.11.11
provider.aws v1.54.0
Confirming this with the following versions.
Terraform v0.12.8
+ provider.aws v2.26.0
The associated changes have been merged and will release with the upcoming v3.0.0 release of the Terraform AWS Provider.
This has been released in version 3.0.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!
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!
Most helpful comment
I can confirm that this is still a problem with AWS provider version 1.46.0
It's actually quite a dangerous bug if the target group it refers to no longer exists; It causes autoscaling to fail to replace instances as they are terminated. In my case, our test environment scales down at night and failed to scale back up in the morning. However, when autoscaling groups are used (as they are most commonly) for 24 hour high availability and self-healing, this self healing would fail to happen in the case of outage / spot price termination etc. This could happen months removed from the terraform change to the ASG.