0

Took over a legacy stack, which creates a bunch of resources with Terraform, one of which is the following asg:

resource "aws_autoscaling_group" "logstashcluster_asg" {
  lifecycle { create_before_destroy = true }

  name                      = "${var.stack_id}-asg"

  vpc_zone_identifier       = ["${data.terraform_remote_state.global.vpc_server_subnet_ids_az}"]
  max_size                  = "${lookup(var.max_count, var.aws_account_id)}"
  min_size                  = "${lookup(var.min_count, var.aws_account_id)}"
  health_check_grace_period = 600
  health_check_type         = "ELB"
  force_delete              = true
  launch_configuration      = "${aws_launch_configuration.cloud_logstashcluster.name}"
  target_group_arns         = ["${aws_lb_target_group.logstashcluster8080.arn}", "${aws_lb_target_group.logstashcluster8081.arn}", "${aws_lb_target_group.logstashcluster.arn}","${aws_lb_target_group.logstashcluster5445.arn}","${aws_lb_target_group.logstashcluster8090.arn}"]

  tags = [
    {
      key = "StackId"
      value = "${var.stack_id}"
      propagate_at_launch = true
    },
    {
      key = "Name"
      value = "${var.stack_id}"
      propagate_at_launch = true
    }
  ]

}

Notice there's no enabled_metrics in it, but when i run it, i got the following log:

aws_autoscaling_group.logstashcluster_asg: Modifying... (ID: cloud-logstashcluster-asg)

  enabled_metrics.#:          "21" => "0"

  enabled_metrics.119681000:  "GroupStandbyInstances" => ""

  enabled_metrics.1196937530: "WarmPoolWarmedCapacity" => ""

  enabled_metrics.1460020489: "GroupAndWarmPoolTotalCapacity" => ""

  enabled_metrics.1940933563: "GroupTotalInstances" => ""

  enabled_metrics.2498709624: "GroupTotalCapacity" => ""

  enabled_metrics.2591500440: "GroupInServiceCapacity" => ""

  enabled_metrics.3061563798: "WarmPoolTerminatingCapacity" => ""

  enabled_metrics.3076096507: "GroupStandbyCapacity" => ""

  enabled_metrics.308948767:  "GroupPendingInstances" => ""

  enabled_metrics.3113454766: "WarmPoolMinSize" => ""

  enabled_metrics.3267518000: "GroupTerminatingInstances" => ""

  enabled_metrics.3360752227: "WarmPoolPendingCapacity" => ""

  enabled_metrics.3394537085: "GroupDesiredCapacity" => ""

  enabled_metrics.3480424646: "GroupAndWarmPoolDesiredCapacity" => ""

  enabled_metrics.3551801763: "GroupInServiceInstances" => ""

  enabled_metrics.3977504579: "GroupTerminatingCapacity" => ""

  enabled_metrics.4118539418: "GroupMinSize" => ""

  enabled_metrics.4136111317: "GroupMaxSize" => ""

  enabled_metrics.4168968189: "WarmPoolTotalCapacity" => ""

  enabled_metrics.628375462:  "GroupPendingCapacity" => ""

  enabled_metrics.661765048:  "WarmPoolDesiredCapacity" => ""



Error: Error applying plan:



1 error occurred:

    * aws_autoscaling_group.logstashcluster_asg: 1 error occurred:

    * aws_autoscaling_group.logstashcluster_asg: Error updating AutoScaling Group Metrics collection: Failure to Disable metrics collection types for ASG cloud-logstashcluster-asg: ValidationError: Valid metrics collection types are: [GroupMinSize, GroupMaxSize, GroupDesiredCapacity, GroupInServiceInstances, GroupInServiceCapacity, GroupPendingInstances, GroupPendingCapacity, GroupTerminatingInstances, GroupTerminatingCapacity, GroupStandbyInstances, GroupStandbyCapacity, GroupTotalInstances, GroupTotalCapacity, WarmPoolMinSize, WarmPoolDesiredCapacity, WarmPoolPendingCapacity, WarmPoolTerminatingCapacity, WarmPoolWarmedCapacity, WarmPoolTotalCapacity, GroupAndWarmPoolDesiredCapacity, GroupAndWarmPoolTotalCapacity].

    status code: 400, request id: 9ed94b27-cc08-4d47-b2d8-829d587f2b64

Not sure if this is because they had metrics before, but shouldn't it just simply get modified/destroyed by TF? why does it complain? Also, i tried adding in enabled_metrics =[] as a empty list, still got the same error. Please help.

JackOuttaBox
  • 345
  • 5
  • 12
  • 1
    How did get this output? This is not from `terraform plan`. – Marcin Apr 07 '21 at 05:29
  • @Marcin I believe this is from terraform apply. – JackOuttaBox Apr 07 '21 at 05:32
  • 1
    So the error occurs when you add `enabled_metrics =[] ` or without it? – Marcin Apr 07 '21 at 05:33
  • Without it, it shouldn't have that, because we are not enabling any metric at the moment. But since the error says it has something to do with metric, so i tried to add an empty list to see if it fixes the issue. it just generate the same error. – JackOuttaBox Apr 07 '21 at 05:39
  • 1
    The metrics probably have been enabled outside of TF, resulting in drift. But this error is strange. What version of TF and aws provider do you use? – Marcin Apr 07 '21 at 05:45
  • it's an old version on our jenkins server: 0.11.14.8. as for the aws provider, not sure what you mean? – JackOuttaBox Apr 07 '21 at 05:50
  • 1
    If you run `terraform --version` if will give you aws provider version as well. But anyway, do you have a possibility of checking on current tf and aws provider versions? – Marcin Apr 07 '21 at 05:54
  • yeah, thinking about updating too, but need to get approval from boss tomorrow, guess i'll let you know tmr. thanks for helping out, appreciate it~ – JackOuttaBox Apr 07 '21 at 06:01

1 Answers1

0

not sure what exacting is causing this, but found a temp workaround by adding this ignore_changes option as follows:

lifecycle {
  ignore_changes = ["tags", "enabled_metrics"]
}
JackOuttaBox
  • 345
  • 5
  • 12