fix: set an ASG's launch template version to an explicit version to automatically trigger instance refresh (#1370)

NOTES: Set an ASG's launch template version to an explicit version automatically. This will ensure that an instance refresh will be triggered whenever the launch template changes. The default `launch_template_version` is now used to determine the latest or default version of the created launch template for self-managed worker groups.

Signed-off-by: Benjamin Ash <bash@intelerad.com>
Co-authored-by: Thierno IB. BARRY <ibrahima.br@gmail.com>
This commit is contained in:
Benjamin Ash
2021-05-19 10:34:59 -04:00
committed by GitHub
parent a639cf5138
commit a2761ad685
3 changed files with 27 additions and 7 deletions

View File

@@ -141,7 +141,13 @@ resource "aws_autoscaling_group" "workers_launch_template" {
version = lookup(
var.worker_groups_launch_template[count.index],
"launch_template_version",
local.workers_group_defaults["launch_template_version"],
lookup(
var.worker_groups_launch_template[count.index],
"launch_template_version",
local.workers_group_defaults["launch_template_version"]
) == "$Latest"
? aws_launch_template.workers_launch_template.*.latest_version[count.index]
: aws_launch_template.workers_launch_template.*.default_version[count.index]
)
}
@@ -169,7 +175,13 @@ resource "aws_autoscaling_group" "workers_launch_template" {
version = lookup(
var.worker_groups_launch_template[count.index],
"launch_template_version",
local.workers_group_defaults["launch_template_version"],
lookup(
var.worker_groups_launch_template[count.index],
"launch_template_version",
local.workers_group_defaults["launch_template_version"]
) == "$Latest"
? aws_launch_template.workers_launch_template.*.latest_version[count.index]
: aws_launch_template.workers_launch_template.*.default_version[count.index]
)
}
}
@@ -278,6 +290,12 @@ resource "aws_launch_template" "workers_launch_template" {
count.index,
)}"
update_default_version = lookup(
var.worker_groups_launch_template[count.index],
"update_default_version",
local.workers_group_defaults["update_default_version"],
)
network_interfaces {
associate_public_ip_address = lookup(
var.worker_groups_launch_template[count.index],