Skip to content

Commit 604fb9a

Browse files
author
Benjamin Ash
committed
fix: Use the default launch_template_version to determine latest versus
default launch_template version. Signed-off-by: Benjamin Ash <[email protected]>
1 parent 5b422fd commit 604fb9a

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

examples/instance_refresh/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ module "eks" {
242242
public_ip = true
243243
metadata_http_put_response_hop_limit = 3
244244
use_latest_version = true
245-
update_default_version = true
246245
instance_refresh_triggers = ["tag"]
247246
tags = [
248247
{

local.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ locals {
7575
root_block_device_name = data.aws_ami.eks_worker.root_device_name # Root device name for workers. If non is provided, will assume default AMI was used.
7676
root_kms_key_id = "" # The KMS key to use when encrypting the root storage device
7777
launch_template_id = null # The id of the launch template used for managed node_groups
78-
launch_template_version = "$Latest" # The latest version of the launch template to use in the autoscaling and node groups. Must be explicitly set in `worker_groups_launch_template`.
79-
use_latest_version = true # Set the autoscaling group to use the latest version of the launch template, otherwise the default template version will be used. Ignored when `launch_template_version` is set in `worker_groups_launch_template`.
78+
launch_template_version = "$Latest" # The latest version of the launch template to use in the autoscaling group
8079
update_default_version = false # Update the autoscaling group launch template's default version upon each update
8180
launch_template_placement_tenancy = "default" # The placement tenancy for instances
8281
launch_template_placement_group = null # The name of the placement group into which to launch the instances, if any.

workers_launch_template.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ resource "aws_autoscaling_group" "workers_launch_template" {
143143
"launch_template_version",
144144
lookup(
145145
var.worker_groups_launch_template[count.index],
146-
"use_latest_version",
147-
local.workers_group_defaults["use_latest_version"]
148-
)
146+
"launch_template_version",
147+
local.workers_group_defaults["launch_template_version"]
148+
) == "$Latest"
149149
? aws_launch_template.workers_launch_template.*.latest_version[count.index]
150150
: aws_launch_template.workers_launch_template.*.default_version[count.index]
151151
)
@@ -177,9 +177,9 @@ resource "aws_autoscaling_group" "workers_launch_template" {
177177
"launch_template_version",
178178
lookup(
179179
var.worker_groups_launch_template[count.index],
180-
"use_latest_version",
181-
local.workers_group_defaults["use_latest_version"]
182-
)
180+
"launch_template_version",
181+
local.workers_group_defaults["launch_template_version"]
182+
) == "$Latest"
183183
? aws_launch_template.workers_launch_template.*.latest_version[count.index]
184184
: aws_launch_template.workers_launch_template.*.default_version[count.index]
185185
)

0 commit comments

Comments
 (0)