feat: Tags passed into worker_groups_launch_template extend var.tags for the volumes (#1397)

This commit is contained in:
Olesia Ivanenko
2021-08-31 16:11:43 +03:00
committed by GitHub
parent e1f54ba73f
commit 8e1d5c11b7
3 changed files with 11 additions and 1 deletions

View File

@@ -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"

View File

@@ -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.

View File

@@ -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"]
}
)
}