Skip to content

Allow user to set name tag value when creating workers using launch templates #1688

@aydasraf

Description

@aydasraf

Is your request related to a new offering from AWS?

No

Is your request related to a problem? Please describe.

Yes, I am creating an EKS cluster using version 17.23.0 using worker_groups_launch_template, I am trying to set name tags for the instances to our naming standard to allow domain join for those nodes, by setting the name tag in the code like below:

tags  = [
          {
            key                 = "Name"
            value               = "xxx-yyy-eks"
            propagate_at_launch = true
          },
          {
            key                 = "ADJoin"
            value               = true
            propagate_at_launch = true
          }
        ]

but sadly the module overrides the works by using force cluster_name - work_group_name-eks_sg, code here:

tag_specifications {
resource_type = "volume"
tags = merge(
{
"Name" = "${local.cluster_name}-${lookup(
var.worker_groups_launch_template[count.index],
"name",
count.index,
)}-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"]
}
)
}
tag_specifications {
resource_type = "instance"
tags = merge(
{
"Name" = "${local.cluster_name}-${lookup(
var.worker_groups_launch_template[count.index],
"name",
count.index,
)}-eks_asg"
},
{ for tag_key, tag_value in var.tags :
tag_key => tag_value
if tag_key != "Name" && !contains([for tag in lookup(var.worker_groups_launch_template[count.index], "tags", local.workers_group_defaults["tags"]) : tag["key"]], tag_key)
}
)
}
tag_specifications {
resource_type = "network-interface"
tags = merge(
{
"Name" = "${local.cluster_name}-${lookup(
var.worker_groups_launch_template[count.index],
"name",
count.index,
)}-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"]
}
)
}
which causes the domain join to fail and the nodes to be outside of our org naming convention causing a huge mess.

Describe the solution you'd like.

if the name tag is set in the tags, respect that and use these values, if not build the value as previously done.

tag_specifications {
resource_type = "volume"
tags = merge(
{
"Name" = "${local.cluster_name}-${lookup(
var.worker_groups_launch_template[count.index],
"name",
count.index,
)}-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"]
}
)
}
tag_specifications {
resource_type = "instance"
tags = merge(
{
"Name" = "${local.cluster_name}-${lookup(
var.worker_groups_launch_template[count.index],
"name",
count.index,
)}-eks_asg"
},
{ for tag_key, tag_value in var.tags :
tag_key => tag_value
if tag_key != "Name" && !contains([for tag in lookup(var.worker_groups_launch_template[count.index], "tags", local.workers_group_defaults["tags"]) : tag["key"]], tag_key)
}
)
}
tag_specifications {
resource_type = "network-interface"
tags = merge(
{
"Name" = "${local.cluster_name}-${lookup(
var.worker_groups_launch_template[count.index],
"name",
count.index,
)}-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"]
}
)
}

Describe alternatives you've considered.

Manually overriding the workers_launch_template.tf to fulfill this, is not convenient and caused a couple of incidents!

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions