Skip to content

Commit 04d4c2c

Browse files
committed
fix: allow nlb to be in public subnets
1 parent da520fb commit 04d4c2c

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module "load_balancer" {
6262
vpc_id = local.vpc_id
6363
vpc_cidr = local.vpc_cidr
6464
vpc_subnets = var.lb_internal ? local.vpc_private_subnets : local.vpc_public_subnets
65+
lb_nlb_subnets = var.lb_nlb_internal ? local.vpc_private_subnets : local.vpc_public_subnets
6566
security_group_id = local.lb_security_group_id
6667
create_ssl_cert = var.create_ssl_cert
6768
alb_certificate_domain = var.alb_certificate_domain

modules/load_balancer/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ resource "aws_lb" "vpces_nlb" {
150150
name = "${var.deployment_name}-nlb"
151151
internal = true
152152
load_balancer_type = "network"
153-
subnets = var.vpc_subnets
153+
subnets = var.lb_nlb_subnets
154154
security_groups = [var.vpces_security_group_id]
155155

156156
enable_cross_zone_load_balancing = true

modules/load_balancer/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ variable "lb_deploy_nlb" {
8989
description = "Flag if the network load balancer should be deployed (usually for incoming private link)."
9090
}
9191

92+
variable "lb_nlb_subnets" {
93+
type = list(any)
94+
description = "List of subnets to deploy the load balancer in"
95+
}
96+
9297
variable "vpces_security_group_id" {
9398
type = string
9499
default = ""

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ variable "lb_deploy_nlb" {
375375
description = "Flag if the network load balancer should be deployed (usually for incoming private link)."
376376
}
377377

378+
variable "lb_nlb_internal" {
379+
type = bool
380+
default = true
381+
description = "Set to true to make the load balancer internal and not exposed to the internet."
382+
}
383+
378384
variable "lb_vpces_details" {
379385
default = null
380386
type = object({

0 commit comments

Comments
 (0)