Skip to content

Commit 03ba3f0

Browse files
obezpalkoCopilot
andauthored
[DEV-2790] add extra tags to subnets (#31)
* DEV-2790 add extra tags to vpc subnets * Update modules/comet_vpc/main.tf Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 13edf19 commit 03ba3f0

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

modules/comet_vpc/main.tf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ locals {
44
resource_name = "comet-${var.environment}"
55
vpc_cidr = var.vpc_cidr
66
azs = slice(data.aws_availability_zones.available.names, 0, 3)
7+
# if EKS deployment, set subnet tags for AWS Load Balancer Controller auto-discovery
8+
public_subnet_tags = var.eks_enabled ? { "kubernetes.io/role/elb" = "1" } : {}
9+
private_subnet_tags = var.eks_enabled ? { "kubernetes.io/role/internal-elb" = "1" } : {}
710
}
811

912
module "vpc" {
@@ -29,9 +32,14 @@ module "vpc" {
2932
manage_default_security_group = true
3033
default_security_group_tags = merge(var.common_tags, { Name = "${local.resource_name}-default" })
3134

32-
# if EKS deployment, set subnet tags for AWS Load Balancer Controller auto-discovery
33-
public_subnet_tags = var.eks_enabled ? { "kubernetes.io/role/elb" = 1 } : null
34-
private_subnet_tags = var.eks_enabled ? { "kubernetes.io/role/internal-elb" = 1 } : null
35+
public_subnet_tags = merge(
36+
local.public_subnet_tags,
37+
var.public_subnet_tags,
38+
)
39+
private_subnet_tags = merge(
40+
local.private_subnet_tags,
41+
var.private_subnet_tags,
42+
)
3543
}
3644

3745
resource "aws_vpc_endpoint" "s3" {
@@ -43,4 +51,4 @@ resource "aws_vpc_endpoint" "s3" {
4351
var.common_tags,
4452
{ Name = "${local.resource_name}-s3-endpoint" }
4553
)
46-
}
54+
}

modules/comet_vpc/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,13 @@ variable "vpc_cidr" {
2929
type = string
3030
default = "10.0.0.0/16"
3131
}
32+
variable "private_subnet_tags" {
33+
type = map(string)
34+
description = "A map of tags for private subnets"
35+
default = {}
36+
}
37+
variable "public_subnet_tags" {
38+
type = map(string)
39+
description = "A map of tags for public subnets"
40+
default = {}
41+
}

0 commit comments

Comments
 (0)