influxdata / terraform-aws-influx

Reusable infrastructure modules for running TICK stack on AWS
https://gruntwork.io/
Apache License 2.0
51 stars 43 forks source link

Chronograf server ASG target groups are getting removed #49

Open Panzki opened 3 years ago

Panzki commented 3 years ago

Problem

Hi, I'm using the terraform modules to run a chronograf and a kapacitor server on AWS. I encountered the problem, that terraform apply would remove the target group from the auto scaling group, even tough there were no real changes to the resources. (This could lead to down time on production systems.) When running terraform apply a second time, terraform would reattach the target group to the ASG. This problem occurs in the AWS terraform provider and it's rerlated to the lifecycle of the ASG. There is this GitHub issue discussing this: https://github.com/hashicorp/terraform-provider-aws/issues/14540

Possible solution

To solve the issue for my project, I forked the this repo and added a lifecycle block to the ASG resource, as suggested in here: https://github.com/hashicorp/terraform-provider-aws/issues/14540#issuecomment-680099770 After running terraform apply the problem was solved.

resource "aws_autoscaling_group" "autoscaling_group" {
  name = var.cluster_name

...

  lifecycle {
    ignore_changes = [load_balancers, target_group_arns]
  }

...

}

The terraform apply did not cause any down time. I'm not sure about backwards compatibility. I'm still running v0.1.2 of the TICK stack modules and had no problems.


I hope you can use this information to create a fix release and thanks for creating and maintaining these module.

brikis98 commented 3 years ago

Ah, you're right, we had to do similar fixes in other modules. E.g., https://github.com/hashicorp/terraform-aws-nomad/pull/78. A PR to do the same here is very welcome!