data "aws_alb" "private_alb" {
  name = "${local.name_prefix}-alb-external-private"
}

data "aws_alb" "nlb" {
  name = "${local.name_prefix}-private-nlb"
}

data "aws_alb_listener" "private_alb_https" {
  load_balancer_arn = data.aws_alb.private_alb.arn
  port              = 443
}

data "aws_alb_listener" "private_alb_http" {
  load_balancer_arn = data.aws_alb.private_alb.arn
  port              = 80
}

data "aws_alb" "internal_alb" {
  name = "${local.name_prefix}-alb-internal"
}

data "aws_alb_listener" "internal_alb_https" {
  load_balancer_arn = data.aws_alb.internal_alb.arn
  port              = 443
}

data "aws_alb_listener" "internal_alb_http" {
  load_balancer_arn = data.aws_alb.internal_alb.arn
  port              = 80
}

#resource "aws_alb_listener_rule" "new_nexus_external_routes_for_python_a" {
#  listener_arn = data.aws_alb_listener.private_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.external_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_external"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/repository/pypi-all/*",
#        "/repository/pypi-internal/*",
#        "/repository/pypi-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_external_routes_for_python_b" {
#  listener_arn = data.aws_alb_listener.private_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.external_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_external"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/service/rest/repository/browse/pypi-all/*",
#        "/service/rest/repository/browse/pypi-internal/*",
#        "/service/rest/repository/browse/pypi-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_external_routes_for_maven_a" {
#  listener_arn = data.aws_alb_listener.private_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.external_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_external"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/repository/maven-releases/*",
#        "/repository/maven-public/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_external_routes_for_maven_b" {
#  listener_arn = data.aws_alb_listener.private_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.external_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_external"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/service/rest/repository/browse/maven-releases/*",
#        "/service/rest/repository/browse/maven-public/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_external_routes_for_node_a" {
#  listener_arn = data.aws_alb_listener.private_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.external_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_external"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/repository/npm-group/*",
#        "/repository/npm-private/*",
#        "/repository/npm-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_external_routes_for_node_b" {
#  listener_arn = data.aws_alb_listener.private_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.external_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_external"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/service/rest/repository/browse/npm-group/*",
#        "/service/rest/repository/browse/npm-private/*",
#        "/service/rest/repository/browse/npm-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_internal_routes_for_python_a" {
#  listener_arn = data.aws_alb_listener.internal_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.internal_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_internal"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/repository/pypi-all/*",
#        "/repository/pypi-internal/*",
#        "/repository/pypi-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_internal_routes_for_python_b" {
#  listener_arn = data.aws_alb_listener.internal_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.internal_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_internal"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/service/rest/repository/browse/pypi-all/*",
#        "/service/rest/repository/browse/pypi-internal/*",
#        "/service/rest/repository/browse/pypi-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_internal_routes_for_maven_a" {
#  listener_arn = data.aws_alb_listener.internal_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.internal_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_internal"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/repository/maven-releases/*",
#        "/repository/maven-public/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_internal_routes_for_maven_b" {
#  listener_arn = data.aws_alb_listener.internal_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.internal_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_internal"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/service/rest/repository/browse/maven-releases/*",
#        "/service/rest/repository/browse/maven-public/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_internal_routes_for_node_a" {
#  listener_arn = data.aws_alb_listener.internal_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.internal_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_internal"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/repository/npm-group/*",
#        "/repository/npm-private/*",
#        "/repository/npm-proxy/*",
#      ]
#    }
#  }
#}
#
#resource "aws_alb_listener_rule" "new_nexus_internal_routes_for_node_b" {
#  listener_arn = data.aws_alb_listener.internal_alb_https.arn
#
#  action {
#    type             = "forward"
#    target_group_arn = aws_lb_target_group.internal_target_group.arn
#  }
#
#  condition {
#    host_header {
#      values = [module.domains.dev["nexus_internal"]]
#    }
#  }
#
#  condition {
#    path_pattern {
#      values = [
#        "/service/rest/repository/browse/npm-group/*",
#        "/service/rest/repository/browse/npm-private/*",
#        "/service/rest/repository/browse/npm-proxy/*",
#      ]
#    }
#  }
#}
