cloudposse/terraform-aws-ec2-autoscale-group

launch_template_version $Latest does not trigger instance refresh when user-data or launch_tempate is updated.

harshitp1987 opened this issue · 2 comments

Describe the Bug

launch_template_version $Latest does not trigger instance refresh when user-data or launch_tempate is updated.

Expected Behavior

When launch_template is updated , the latest version should be picked up by Autoscaling group and it should trigger instance refresh

Steps to Reproduce

Steps to reproduce the behavior:

  1. Update the user-data or instance type or AMI
  2. run terraform apply
  3. it should show the launchtemplate update
  4. it updates the launch template but, does not trigger instance refresh

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: Amazon Linux2

With Terraform 1.2, I think we can fix this. We can have a structure like this:

resource "aws_lt" "this" {
...
}

data "aws_lt" "this" {
  id = aws_lt.this.id
}

resource "aws_autoscale_group" "this" {
  lt = data.aws_ld.this.version
}

Does this make sense? Any objections if I implement?

After trying to solve this issue in my company, I realized the issue lies with the conditional on the version inside the locals launch template block. To get the old behavior, set the var.launch_template_version to an empty string ""