diff --git a/examples/eks_test_fixture/main.tf b/examples/eks_test_fixture/main.tf index abc7bc1..ec9c12c 100644 --- a/examples/eks_test_fixture/main.tf +++ b/examples/eks_test_fixture/main.tf @@ -31,6 +31,7 @@ data "http" "workstation_external_ip" { locals { workstation_external_cidr = "${chomp(data.http.workstation_external_ip.body)}/32" + cluster_name = "test-eks-${random_string.suffix.result}" tags = "${map("Environment", "test", "GithubRepo", "terraform-aws-eks", @@ -54,7 +55,7 @@ module "vpc" { public_subnets = ["10.0.3.0/24", "10.0.4.0/24"] enable_nat_gateway = true single_nat_gateway = true - tags = "${local.tags}" + tags = "${merge(local.tags, map("kubernetes.io/cluster/${local.cluster_name}", "shared"))}" } module "security_group" { @@ -67,7 +68,7 @@ module "security_group" { module "eks" { source = "../.." - cluster_name = "test-eks-${random_string.suffix.result}" + cluster_name = "${local.cluster_name}" subnets = "${module.vpc.public_subnets}" tags = "${local.tags}" vpc_id = "${module.vpc.vpc_id}" diff --git a/workers.tf b/workers.tf index 8da1abe..1e148e5 100644 --- a/workers.tf +++ b/workers.tf @@ -9,6 +9,7 @@ resource "aws_autoscaling_group" "workers" { tags = ["${concat( list( map("key", "Name", "value", "${var.cluster_name}-eks_asg", "propagate_at_launch", true), + map("key", "kubernetes.io/cluster/${var.cluster_name}", "value", "owned", "propagate_at_launch", true), ), local.asg_tags) }"] @@ -32,7 +33,8 @@ resource "aws_security_group" "workers" { name_prefix = "${var.cluster_name}" description = "Security group for all nodes in the cluster." vpc_id = "${var.vpc_id}" - tags = "${merge(var.tags, map("Name", "${var.cluster_name}-eks_worker_sg"))}" + tags = "${merge(var.tags, map("Name", "${var.cluster_name}-eks_worker_sg", "kubernetes.io/cluster/${var.cluster_name}", "owned" + ))}" } resource "aws_security_group_rule" "workers_egress_internet" {