terraform-aws-modules / terraform-aws-autoscaling

Terraform module to create AWS Auto Scaling resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws
Apache License 2.0
292 stars 556 forks source link

LT User Data Update Requires Two Applies to Update ASG #171

Closed stewartcampbell closed 2 years ago

stewartcampbell commented 2 years ago

Description

When I make a change to EC2 userdata, the first plan/apply only updates the LT. I need a second plan/apply to update the ASG. Is this expected? Thanks.

Versions

Terraform v1.0.11 on linux_amd64

Code Snippet to Reproduce

locals {
  user_data = <<-EOT
  #!/bin/bash -xe
  ...
...
  update_default_version = true
  use_lt                 = true
  user_data_base64       = base64encode(local.user_data)
  vpc_zone_identifier    = var.private_subnet_ids
}

Expected behavior

ASG updates at the same time as LT.

Actual behavior

Requires two updates.

bryantbiggs commented 2 years ago

hi @stewartcampbell - this is because of using the default version and updating the default version. the rough sequence of steps are as follows: 1) Change is detected on LT and therefore version should be updated 2) Default version is now one version behind, update default version

If you want to avoid this, I believe you should be able to set lt_version = "$Latest" and this will update in one apply (its been a minute but I believe this is the correct route to achieve your outcome). Try it out and let me know

stewartcampbell commented 2 years ago

Hi @bryantbiggs. Thanks for the response.

100% works. I totally forgot you could set the version to latest for an ASG LT :)

Thanks again.

github-actions[bot] commented 1 year ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.