-
-
Couldn't load subscription status.
- Fork 4.3k
Description
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:
terraform-aws-eks/workers_launch_template.tf
Lines 550 to 606 in 4e54eaa
| 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 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.
terraform-aws-eks/workers_launch_template.tf
Lines 550 to 606 in 4e54eaa
| 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