Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch Template in AutoScaling group is not updated on change #22428

Closed
vikas027 opened this issue Jan 6, 2022 · 3 comments
Closed

Launch Template in AutoScaling group is not updated on change #22428

vikas027 opened this issue Jan 6, 2022 · 3 comments
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@vikas027
Copy link

vikas027 commented Jan 6, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

I don't think the terraform version matters here, I have tried with both terraform versions 1.1.2 and 0.13.6.
As per my testing, the problem lies with terraform provider version. v3.38 works fine while 3.69.0 and 3.70.0 definitely has issues. I am not sure in which version the bug was introduced.

Affected Resource(s)

  • aws_autoscaling_group
  • aws_launch_template

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

# Launch Template
resource "aws_launch_template" "this" {
  …
}

# AutoScaling Group
resource "aws_autoscaling_group" "this" {
  depends_on = [aws_launch_template.this]

  launch_template {
    id      = aws_launch_template.this.id
    version = aws_launch_template.this.latest_version
  }
  …
  instance_refresh {
    strategy = "Rolling"
    preferences {
      min_healthy_percentage = 50
    }
  }
}

Expected Behavior

When there is a change in the launch template, the version of the launch template should be bumped (say 1 to 2) and should update the launch template version mapped to the AutoScaling group too.

Actual Behavior

Somewhere between versions 3.38.0 and 3.69.0, a bug has been introduced which bumps up the version of the launch template but not one mapped to the AutoScaling Group.

Steps to Reproduce

See this example

  • In the first run (terraform apply), the launch template was created with v1 and the autoscaling group was too created with launch template v1
  • Now, when a change is made to user data (just an example) which forces a change in the launch template, in the next run (terraform apply) launch template version is bumped from v1 to v2 but it does not gets changed in the ASG.
    There is a mismatch of the launch template latest version and the version in the ASG.
  • In the subsequent run, the launch template version in the ASG gets updated to v2 and the instance refresh kicks in.
  • Note, if we make another change to the launch template without applying it first, we get below error. This is because, now the launch template is at v3 but the ASG is still at v1.
Error: Provider produced inconsistent final plan

When expanding the plan for aws_autoscaling_group.this to include
new values learned so far during apply, provider
"registry.terraform.io/hashicorp/aws" produced an invalid new value for
.launch_template[0].version: was cty.StringVal("2"), but now
cty.StringVal("3").

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

References

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jan 6, 2022
@ericrichtert
Copy link
Contributor

Check the release notes for 3.71. I guess it will released the tomorrow

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jan 6, 2022
@ewbankkit
Copy link
Contributor

@vikas027 Thanks for raising this issue.
It has already been noticed in #22015. I'm going to close this one as a duplicate so that we can concentrate discussion in the linked issue.
Please add any additional comments there.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

3 participants