Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ability to tag network-interface using Launch Template #1563

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ resource "aws_launch_template" "default" {
}
}

# Supplying custom tags to EKS instances ENI's is another use-case for LaunchTemplates
tag_specifications {
resource_type = "network-interface"

tags = {
CustomTag = "EKS example"
}
}

# Tag the LT itself
tags = {
CustomTag = "EKS example"
Expand Down
14 changes: 14 additions & 0 deletions modules/node_groups/launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ resource "aws_launch_template" "workers" {
)
}

# Supplying custom tags to EKS instances ENI's is another use-case for LaunchTemplates
tag_specifications {
resource_type = "network-interface"

tags = merge(
var.tags,
{
Name = local.node_groups_names[each.key]
},
lookup(var.node_groups_defaults, "additional_tags", {}),
lookup(var.node_groups[each.key], "additional_tags", {})
)
}

# Tag the LT itself
tags = merge(
var.tags,
Expand Down
20 changes: 20 additions & 0 deletions workers_launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,26 @@ resource "aws_launch_template" "workers_launch_template" {
)
}

tag_specifications {
resource_type = "network-interface"

tags = merge(
{
"Name" = "${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}-${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"]
}
)
}

tags = var.tags

lifecycle {
Expand Down