Terraform-provider-aws: Removing target groups from aws_autoscaling_group does not remove it on AWS

Created on 6 Feb 2018  ยท  6Comments  ยท  Source: hashicorp/terraform-provider-aws

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

Terraform Version

v0.11.1

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_autoscaling_group

Terraform Configuration Files

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
  }
}

Expected Behavior

Terraform should have removed the target group from the ASG on AWS

Actual Behavior

The ASG remained attached to the ASG

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
  2. comment out target_group_arns
  3. terraform apply - nothing to change
bug servicautoscaling servicelbv2

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.

All 6 comments

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.

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsi-p picture jsi-p  ยท  33Comments

hashibot picture hashibot  ยท  38Comments

gazoakley picture gazoakley  ยท  40Comments

loivis picture loivis  ยท  41Comments

oarmstrong picture oarmstrong  ยท  44Comments