From 504bc3c9d9c5b20f19c2d9b28d7f3d886e0ad29d Mon Sep 17 00:00:00 2001 From: trpfs98 Date: Mon, 17 May 2021 12:02:23 -0400 Subject: [PATCH 1/3] adding eni tags --- workers_launch_template.tf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/workers_launch_template.tf b/workers_launch_template.tf index 14564c1708..9a829d00af 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -507,6 +507,24 @@ 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" + }, + { 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) + } + ) + } + tags = var.tags lifecycle { From 1e3417fb4ab651b6d46e1ddc49f274408fd5b157 Mon Sep 17 00:00:00 2001 From: trpfs98 Date: Mon, 17 May 2021 12:51:31 -0400 Subject: [PATCH 2/3] adding eni tags --- modules/node_groups/launchtemplate.tf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/node_groups/launchtemplate.tf b/modules/node_groups/launchtemplate.tf index 1da04e2037..8a87be3112 100644 --- a/modules/node_groups/launchtemplate.tf +++ b/modules/node_groups/launchtemplate.tf @@ -98,6 +98,25 @@ resource "aws_launch_template" "workers" { ) } + # Supplying custom tags to EKS instances ENI's + 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" + }, + { 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 the LT itself tags = merge( var.tags, From 80c967d69f74ff02b2db52254faa56daf38122d9 Mon Sep 17 00:00:00 2001 From: trpfs98 Date: Mon, 17 May 2021 12:52:36 -0400 Subject: [PATCH 3/3] adding eni tags --- modules/node_groups/launchtemplate.tf | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/node_groups/launchtemplate.tf b/modules/node_groups/launchtemplate.tf index 8a87be3112..7b50350dd2 100644 --- a/modules/node_groups/launchtemplate.tf +++ b/modules/node_groups/launchtemplate.tf @@ -98,21 +98,16 @@ resource "aws_launch_template" "workers" { ) } - # Supplying custom tags to EKS instances ENI's + # Supplying custom tags to EKS instances ENI's tag_specifications { resource_type = "network-interface" tags = merge( + var.tags, + lookup(var.node_groups_defaults, "additional_tags", {}), + lookup(var.node_groups[each.key], "additional_tags", {}), { - "Name" = "${coalescelist(aws_eks_cluster.this[*].name, [""])[0]}-${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) + Name = lookup(each.value, "name", join("-", [var.cluster_name, each.key, random_pet.node_groups[each.key].id])) } ) }