Skip to content

Commit

Permalink
Merge pull request #190 from tablexi/va-add-elb-tags-to-eks-subnets
Browse files Browse the repository at this point in the history
Add tags to EKS-related subnets to support discovery for ELB
  • Loading branch information
vandrijevik authored Feb 2, 2021
2 parents 376c595 + f8419a8 commit d9c8204
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
21 changes: 10 additions & 11 deletions aws/eks/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
locals {
tags = merge({ Name = var.name }, var.tags)
elb_discovery_tag = var.uses_nat_gateway ? "kubernetes.io/role/internal-elb" : "kubernetes.io/role/elb"
tags = merge({ Name = var.name }, var.tags)

subnet_tags = merge(local.tags, {
(local.elb_discovery_tag) = true,
"kubernetes.io/cluster/${var.name}" = "shared"
})
}

module "eks-vpc" {
Expand Down Expand Up @@ -35,17 +41,10 @@ module "eks-subnets" {
source = "../vpc/subnets"

exclude_names = var.subnet_module.exclude_names
netnum_offset = var.subnet_module.netnum_offset

internet_gateway_id = module.eks-vpc.internet_gateway_id
nat_gateway_id = var.uses_nat_gateway ? module.eks-vpc-nat-gateway[0].nat_gateway_id : 0

tags = merge(
local.tags,
{
"kubernetes.io/cluster/${var.name}" = "shared"
},
)
nat_gateway_id = var.uses_nat_gateway ? module.eks-vpc-nat-gateway[0].nat_gateway_id : 0
netnum_offset = var.subnet_module.netnum_offset
tags = local.subnet_tags
vpc_id = module.eks-vpc.vpc_id
}

Expand Down
10 changes: 7 additions & 3 deletions aws/nat_gateway/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
subnet_tags = merge(var.tags, { "kubernetes.io/role/elb" = true })
}

# Create subnets for use by the LoadBalancer for ingress
# And use the first of these subnets for the NAT Gateway

Expand All @@ -18,14 +22,14 @@ resource "aws_subnet" "mod" {
var.subnet_cidr_netnum_offset + count.index + 1,
)
map_public_ip_on_launch = true
tags = var.tags
tags = local.subnet_tags
vpc_id = var.vpc_id
}

# ElasticIP address for use with the NAT Gateway
resource "aws_eip" "nat-gw-eip" {
vpc = true
tags = var.tags
vpc = true
tags = var.tags
}

# NAT Gateway in the first subnet
Expand Down

0 comments on commit d9c8204

Please sign in to comment.