# ============================================================================= # Gateway Load Balancer # El GWLB encapsula en GENEVE (UDP 6081) y reparte hacia los VM-Series. # Los firewalls trabajan como bump-in-the-wire: no rutean, no hacen NAT. # ============================================================================= resource "aws_lb" "gwlb" { name = "kf-gwlb" load_balancer_type = "gateway" subnets = [for k, v in aws_subnet.fwdata : v.id] # Probado en true (2026-08-17) para descartar que fuera la causa de que el # GWLB no entregue al target: NO cambio nada, el trafico sigue muriendo entre # el endpoint y el target. Se vuelve a false, que es el diseno buscado # (inspeccion local por AZ) y evita cargos de trafico cross-AZ. enable_cross_zone_load_balancing = false tags = { Name = "kf-gwlb" } } # GOTCHA GWLB #2: el health check no puede pegarle a un path cualquiera del # PAN-OS. Se usa TCP:80 y hay que habilitar HTTP en el interface management # profile de la interfaz de datos, o el target nunca pasa a healthy. resource "aws_lb_target_group" "fw" { name = "kf-gwlb-tg" target_type = "ip" protocol = "GENEVE" port = 6081 vpc_id = aws_vpc.lab.id health_check { protocol = "TCP" port = 80 interval = 10 healthy_threshold = 3 unhealthy_threshold = 3 } # El firewall no reescribe la 5-tupla, asi que el flujo debe volver siempre # a la misma instancia. stickiness { type = "source_ip_dest_ip_proto" enabled = true } tags = { Name = "kf-gwlb-tg" } } # Se registra la IP de la ENI de datos, no el instance-id: con target_type # "instance" el GWLB usaria la interfaz primaria, que aca es la de gestion. resource "aws_lb_target_group_attachment" "fw" { for_each = local.subnets target_group_arn = aws_lb_target_group.fw.arn target_id = aws_network_interface.fw_data[each.key].private_ip availability_zone = local.az[each.key] port = 6081 } resource "aws_lb_listener" "gwlb" { load_balancer_arn = aws_lb.gwlb.arn default_action { type = "forward" target_group_arn = aws_lb_target_group.fw.arn } } # --- Endpoint service + endpoints por AZ ------------------------------------- resource "aws_vpc_endpoint_service" "gwlb" { acceptance_required = false gateway_load_balancer_arns = [aws_lb.gwlb.arn] tags = { Name = "kf-gwlb-endpoint-service" } } resource "aws_vpc_endpoint" "gwlbe" { for_each = local.subnets vpc_id = aws_vpc.lab.id service_name = aws_vpc_endpoint_service.gwlb.service_name vpc_endpoint_type = "GatewayLoadBalancer" subnet_ids = [aws_subnet.gwlbe[each.key].id] tags = { Name = "kf-gwlbe-${each.key}" } }