gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.11k stars 1.72k forks source link

Run an ASG instance refresh on TF configuration change #25259

Open hugoShaka opened 1 year ago

hugoShaka commented 1 year ago

What would you like Teleport to do?

As a user editing the Teleport ASG with Terraform (updating config or Teleport version) I want the changes to apply immediately.

What problem does this solve?

Changes in configuration don't trigger an instance refresh, thus are not applied unless machines are deleted/restarted. This causes a lot of confusion and time lost troubleshooting why the configuration change did not apply. This can also cause security issues when users think they have updated to a version containing a security fix while still running vulnerable images.

If a workaround exists, please include it.

Trigger instance rollout manually.

Implementation details

See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group#automatically-refresh-all-instances-after-the-group-is-updated

GavinFrazar commented 3 weeks ago

template changes will trigger a refresh by default, unless you use version = "$Latest" instead of referring to the template latest version:

A refresh will not start when version = "$Latest" is configured in the launch_template block. To trigger the instance refresh when a launch template is changed, configure version to use the latest_version attribute of the aws_launch_template resource.

Thus the fix is to change these config blocks like so:

  launch_template {
    name    = aws_launch_template.proxy.name
-   version = "$Latest"
+   version = aws_launch_template.proxy.latest_version
  }