diff --git a/modules/gwlb/main.tf b/modules/gwlb/main.tf index d4bd7c1..231f2e0 100755 --- a/modules/gwlb/main.tf +++ b/modules/gwlb/main.tf @@ -19,6 +19,9 @@ module "gateway_load_balancer" { listener_port = 6081 cross_zone_load_balancing = var.enable_cross_zone_load_balancing ip_mode = var.ip_mode + + // default tcp timeout 1 hour + tcp_idle_timeout = 3600 } resource "aws_vpc_endpoint_service" "gwlb_endpoint_service" { diff --git a/modules/load_balancer/main.tf b/modules/load_balancer/main.tf index 9bc4f5c..3e341df 100755 --- a/modules/load_balancer/main.tf +++ b/modules/load_balancer/main.tf @@ -30,6 +30,7 @@ resource "aws_lb_listener" "lb_listener" { certificate_arn = var.certificate_arn protocol = var.load_balancers_type != "gateway" ? var.load_balancer_protocol : null port = var.load_balancers_type != "gateway" ? var.listener_port : null + tcp_idle_timeout_seconds = var.tcp_idle_timeout > 0 ? var.tcp_idle_timeout : null default_action { type = "forward" target_group_arn = aws_lb_target_group.lb_target_group.arn diff --git a/modules/load_balancer/variables.tf b/modules/load_balancer/variables.tf index 8aa78c7..f8c744c 100755 --- a/modules/load_balancer/variables.tf +++ b/modules/load_balancer/variables.tf @@ -60,6 +60,17 @@ variable "health_check_protocol" { type = string default = null } + +variable "tcp_idle_timeout" { + description = "The idle timeout of the load balancer." + type = number + default = null + validation { + condition = var.tcp_idle_timeout == null || (var.tcp_idle_timeout >= 60 && var.tcp_idle_timeout <= 6000) + error_message = "The tcp_idle_timeout value must be between 60 and 6000 seconds" + } +} + variable "ip_mode" { type = string description = "IP mode of AWS resources."