Skip to content

Commit

Permalink
Fix security group protocol issues
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed May 26, 2024
1 parent 165c8ed commit 40ef886
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/alb/security-group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {

module "security_group" {
source = "tedilabs/network/aws//modules/security-group"
version = "~> 0.31.0"
version = "~> 0.32.0"

count = var.default_security_group.enabled ? 1 : 0

Expand All @@ -29,7 +29,7 @@ module "security_group" {
for listener in var.listeners : {
id = "listener-${listener.port}"
description = "Default rule for the load balancer listener."
protocol = listener.protocol
protocol = "tcp"
from_port = listener.port
to_port = listener.port

Expand Down
28 changes: 24 additions & 4 deletions modules/nlb/security-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {

module "security_group" {
source = "tedilabs/network/aws//modules/security-group"
version = "~> 0.31.0"
version = "~> 0.32.0"

count = var.default_security_group.enabled ? 1 : 0

Expand All @@ -29,7 +29,7 @@ module "security_group" {
for listener in var.listeners : {
id = "listener-${listener.port}"
description = "Default rule for the load balancer listener."
protocol = listener.protocol
protocol = "tcp"
from_port = listener.port
to_port = listener.port

Expand All @@ -38,13 +38,33 @@ module "security_group" {
prefix_lists = var.default_security_group.listener_ingress_prefix_lists
security_groups = var.default_security_group.listener_ingress_security_groups
}
if anytrue([
if contains(["TCP", "TLS", "TCP_UDP"], listener.protocol) && anytrue([
length(var.default_security_group.listener_ingress_ipv4_cidrs) > 0,
length(var.default_security_group.listener_ingress_ipv6_cidrs) > 0,
length(var.default_security_group.listener_ingress_prefix_lists) > 0,
length(var.default_security_group.listener_ingress_security_groups) > 0,
])
]
],
[
for listener in var.listeners : {
id = "listener-${listener.port}-udp"
description = "Default rule for the load balancer listener."
protocol = "udp"
from_port = listener.port
to_port = listener.port

ipv4_cidrs = var.default_security_group.listener_ingress_ipv4_cidrs
ipv6_cidrs = var.default_security_group.listener_ingress_ipv6_cidrs
prefix_lists = var.default_security_group.listener_ingress_prefix_lists
security_groups = var.default_security_group.listener_ingress_security_groups
}
if contains(["UDP"], listener.protocol) && anytrue([
length(var.default_security_group.listener_ingress_ipv4_cidrs) > 0,
length(var.default_security_group.listener_ingress_ipv6_cidrs) > 0,
length(var.default_security_group.listener_ingress_prefix_lists) > 0,
length(var.default_security_group.listener_ingress_security_groups) > 0,
])
],
)
egress_rules = concat(
var.default_security_group.egress_rules,
Expand Down

0 comments on commit 40ef886

Please sign in to comment.