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

More options for starting an instance refresh in ASG #16849

Closed
cajund opened this issue Dec 19, 2020 · 11 comments
Closed

More options for starting an instance refresh in ASG #16849

cajund opened this issue Dec 19, 2020 · 11 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/autoscaling Issues and PRs that pertain to the autoscaling service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@cajund
Copy link

cajund commented Dec 19, 2020

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

$ terraform -v
Terraform v0.13.4

  • Installed hashicorp/aws v3.22.0 (signed by HashiCorp)

Affected Resource(s)

Referring to 16678 which was released last night. Is there a way to trigger an instance refresh when the AMI ID changes in the launch template? Is this only triggered when the launch_template value changes on the aws_autoscaling_group resource? Or can it be triggered when the launch template resource changes that the aws_autoscaling_group.launch_template refers to?

Thanks.

References

#16678

@cajund cajund added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 19, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Dec 19, 2020
@ewbankkit ewbankkit added the service/autoscaling Issues and PRs that pertain to the autoscaling service. label Dec 21, 2020
@kumaranbsundar
Copy link

kumaranbsundar commented Jan 21, 2021

One way you can force an instance refresh is via Tags.

I added the following tag to ASG resource
tag {
key = "AMI-ID"
value = var.AMI_ID
propagate_at_launch = false
}

and set the instance refresh to be triggered on tags like this....
instance_refresh {
strategy = "Rolling"
preferences {
min_healthy_percentage = 90
}
triggers = ["tag"]
}

Now every time the AMI ID is updated via AMI_ID variable, it triggers the refresh automatically.

Hope this helps!

@pascal-hofmann
Copy link
Contributor

For me instance refresh works on changes to launch templates with these lines:

resource "aws_autoscaling_group" "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
    }
  }
}

@tx-kstav
Copy link

@pascal-hofmann does the above work for you if you change just the ami of the launch template a couple of times?
@kumaranbsundar 's solution with tags works for me (for changing just the ami in the LT), but I have not had any luck without the tags.

@pascal-hofmann
Copy link
Contributor

Yes, that works for me with just a changed AMI.

@kwunlyou
Copy link

kwunlyou commented May 4, 2021

For me instance refresh works on changes to launch templates with these lines:

resource "aws_autoscaling_group" "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
    }
  }
}

Unfortunately, it doesn't here. I noticed the version is always "$Latest" and can't trigger instance refresh. Anyone else has the same problem?

@tx-kstav
Copy link

tx-kstav commented May 4, 2021

Yes @kwunlyou, even though pascal-hofmann says it's working for them, it doesn't for me. Using the ami_id in a tag, as a workaround that kumaranbsundar also mentioned above, is working fine for me until this is properly fixed.

@prachikhadke
Copy link

prachikhadke commented Jul 9, 2021

One way you can force an instance refresh is via Tags.

I added the following tag to ASG resource
tag {
key = "AMI-ID"
value = var.AMI_ID
propagate_at_launch = false
}

and set the instance refresh to be triggered on tags like this....
instance_refresh {
strategy = "Rolling"
preferences {
min_healthy_percentage = 90
}
triggers = ["tag"]
}

Now every time the AMI ID is updated via AMI_ID variable, it triggers the refresh automatically.

Hope this helps!

What about if i'm using aws_ami to pull in the ami_id dynamically in the autoscaling group. If I run terraform apply and a new ami is pulled and used in the autoscaling group, will it also, trigger the refresh? Do I still need tags? What other kind of triggers exist? I couldn't find more documentation.

  data "aws_ami" "example_ami" {

    # self means the current account

    most_recent      = true
    owners           = ["self"]

    filter {
      name = "state"
      values = ["available"]
    }

    filter {
      name   = "tag:Name"
      values = ["example-ami"]
    }
  }

  module "example_asg" {
    source                  = "terraform-aws-modules/autoscaling/aws"
    version                 = "4.1.0"
    image_id                = data.aws_ami.example_ami.image_id

    instance_refresh = {
      strategy = "Rolling"
      preferences = {
        min_healthy_percentage = 50
      }
      triggers = []
    }

    ...

  }

@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 8, 2021
@carsondoesbusiness
Copy link

Any updates on this? I am facing the same issue where a launch_template update is not triggering a refresh

@Sanverik
Copy link

@carsondoesbusiness the same problem. Have you already found a solution how to fix it?

Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Dec 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2024
Copy link

github-actions bot commented Mar 5, 2024

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 Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/autoscaling Issues and PRs that pertain to the autoscaling service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

10 participants