Skip to content

Commit 7512f17

Browse files
authored
feat: Add ability to tag network-interface using Launch Template (#1563)
1 parent 013afb0 commit 7512f17

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

examples/launch_templates_with_managed_node_groups/launchtemplate.tf

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ resource "aws_launch_template" "default" {
8080
}
8181
}
8282

83+
# Supplying custom tags to EKS instances ENI's is another use-case for LaunchTemplates
84+
tag_specifications {
85+
resource_type = "network-interface"
86+
87+
tags = {
88+
CustomTag = "EKS example"
89+
}
90+
}
91+
8392
# Tag the LT itself
8493
tags = {
8594
CustomTag = "EKS example"

modules/node_groups/launch_template.tf

+14
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ resource "aws_launch_template" "workers" {
103103
)
104104
}
105105

106+
# Supplying custom tags to EKS instances ENI's is another use-case for LaunchTemplates
107+
tag_specifications {
108+
resource_type = "network-interface"
109+
110+
tags = merge(
111+
var.tags,
112+
{
113+
Name = local.node_groups_names[each.key]
114+
},
115+
lookup(var.node_groups_defaults, "additional_tags", {}),
116+
lookup(var.node_groups[each.key], "additional_tags", {})
117+
)
118+
}
119+
106120
# Tag the LT itself
107121
tags = merge(
108122
var.tags,

workers_launch_template.tf

+20
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,26 @@ resource "aws_launch_template" "workers_launch_template" {
573573
)
574574
}
575575

576+
tag_specifications {
577+
resource_type = "network-interface"
578+
579+
tags = merge(
580+
{
581+
"Name" = "${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}-${lookup(
582+
var.worker_groups_launch_template[count.index],
583+
"name",
584+
count.index,
585+
)}-eks_asg"
586+
},
587+
var.tags,
588+
{
589+
for tag in lookup(var.worker_groups_launch_template[count.index], "tags", local.workers_group_defaults["tags"]) :
590+
tag["key"] => tag["value"]
591+
if tag["key"] != "Name" && tag["propagate_at_launch"]
592+
}
593+
)
594+
}
595+
576596
tags = var.tags
577597

578598
lifecycle {

0 commit comments

Comments
 (0)