From 8e1d5c11b798259c67f308d7f6c8afc5dfe14e9d Mon Sep 17 00:00:00 2001 From: Olesia Ivanenko Date: Tue, 31 Aug 2021 16:11:43 +0300 Subject: [PATCH] feat: Tags passed into worker_groups_launch_template extend var.tags for the volumes (#1397) --- examples/launch_templates/main.tf | 5 +++++ local.tf | 2 +- workers_launch_template.tf | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/launch_templates/main.tf b/examples/launch_templates/main.tf index c01256f..cc1cbfb 100644 --- a/examples/launch_templates/main.tf +++ b/examples/launch_templates/main.tf @@ -53,6 +53,11 @@ module "eks" { instance_type = "t3.small" asg_desired_capacity = 2 public_ip = true + tags = [{ + key = "ExtraTag" + value = "TagValue" + propagate_at_launch = true + }] }, { name = "worker-group-2" diff --git a/local.tf b/local.tf index d31f1c9..fbaa04f 100644 --- a/local.tf +++ b/local.tf @@ -49,7 +49,7 @@ locals { policy_arn_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy" workers_group_defaults_defaults = { 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. - tags = [] # A list of map defining extra tags to be applied to the worker group autoscaling group. + tags = [] # A list of maps defining extra tags to be applied to the worker group autoscaling group and volumes. 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. 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. 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. diff --git a/workers_launch_template.tf b/workers_launch_template.tf index 6e14b7d..d1d4818 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -547,6 +547,11 @@ resource "aws_launch_template" "workers_launch_template" { )}-eks_asg" }, var.tags, + { + for tag in lookup(var.worker_groups_launch_template[count.index], "tags", local.workers_group_defaults["tags"]) : + tag["key"] => tag["value"] + if tag["key"] != "Name" && tag["propagate_at_launch"] + } ) }