Skip to content

Commit 8e1d5c1

Browse files
authored
feat: Tags passed into worker_groups_launch_template extend var.tags for the volumes (#1397)
1 parent e1f54ba commit 8e1d5c1

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

examples/launch_templates/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ module "eks" {
5353
instance_type = "t3.small"
5454
asg_desired_capacity = 2
5555
public_ip = true
56+
tags = [{
57+
key = "ExtraTag"
58+
value = "TagValue"
59+
propagate_at_launch = true
60+
}]
5661
},
5762
{
5863
name = "worker-group-2"

local.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ locals {
4949
policy_arn_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy"
5050
workers_group_defaults_defaults = {
5151
name = "count.index" # Name of the worker group. Literal count.index will never be used but if name is not set, the count.index interpolation will be used.
52-
tags = [] # A list of map defining extra tags to be applied to the worker group autoscaling group.
52+
tags = [] # A list of maps defining extra tags to be applied to the worker group autoscaling group and volumes.
5353
ami_id = "" # AMI ID for the eks linux based workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI based on platform.
5454
ami_id_windows = "" # AMI ID for the eks windows based workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI based on platform.
5555
asg_desired_capacity = "1" # Desired worker capacity in the autoscaling group and changing its value will not affect the autoscaling group's desired capacity because the cluster-autoscaler manages up and down scaling of the nodes. Cluster-autoscaler add nodes when pods are in pending state and remove the nodes when they are not required by modifying the desired_capacity of the autoscaling group. Although an issue exists in which if the value of the asg_min_size is changed it modifies the value of asg_desired_capacity.

workers_launch_template.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ resource "aws_launch_template" "workers_launch_template" {
547547
)}-eks_asg"
548548
},
549549
var.tags,
550+
{
551+
for tag in lookup(var.worker_groups_launch_template[count.index], "tags", local.workers_group_defaults["tags"]) :
552+
tag["key"] => tag["value"]
553+
if tag["key"] != "Name" && tag["propagate_at_launch"]
554+
}
550555
)
551556
}
552557

0 commit comments

Comments
 (0)