nlb.tf 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Nessus manager might need an NLB:
  2. ## untested, but i didn't want to mess with the certificate on the Nessus Manager.
  3. ## I have a hunch that the agent is checking the CA of the certificate.
  4. ## This nlb is specifically for LCP nodes to connect.
  5. module "public_dns_record_nessus-manager-nlb" {
  6. source = "../../../submodules/dns/public_ALIAS_record"
  7. name = "nessus-manager.${var.dns_info["public"]["zone"]}"
  8. target_dns_name = aws_lb.external.dns_name
  9. target_zone_id = aws_lb.external.zone_id
  10. dns_info = var.dns_info
  11. providers = {
  12. aws.mdr-common-services-commercial = aws.mdr-common-services-commercial
  13. }
  14. }
  15. resource "aws_lb" "external" {
  16. name = "nessus-manager-external-nlb"
  17. load_balancer_type = "network"
  18. internal = false
  19. subnets = var.public_subnets
  20. access_logs {
  21. bucket = "xdr-elb-${ var.environment }"
  22. enabled = true
  23. }
  24. enable_cross_zone_load_balancing = true
  25. idle_timeout = 300
  26. tags = merge(var.standard_tags, var.tags)
  27. }
  28. resource "aws_lb_listener" "nlb_443" {
  29. load_balancer_arn = aws_lb.external.arn
  30. port = "443"
  31. protocol = "TCP"
  32. default_action {
  33. type = "forward"
  34. target_group_arn = aws_lb_target_group.external.arn
  35. }
  36. }
  37. resource "aws_lb_target_group" "external" {
  38. name = "nessus-manager-external-nlb"
  39. port = 8834
  40. protocol = "TCP"
  41. vpc_id = var.vpc_id
  42. target_type = "instance"
  43. health_check {
  44. enabled = true
  45. #healthy_threshold = 3
  46. #unhealthy_threshold = 2
  47. timeout = 10
  48. interval = 10
  49. #matcher = "200,302"
  50. path = "/"
  51. protocol = "HTTPS"
  52. }
  53. stickiness {
  54. enabled = true
  55. type = "source_ip" # only option for NLBs
  56. }
  57. }
  58. # Create a new load balancer attachment
  59. resource "aws_lb_target_group_attachment" "external_attachment" {
  60. count = var.nessus_manager_count
  61. target_group_arn = aws_lb_target_group.external.arn
  62. target_id = aws_instance.nessus-manager-instance[count.index].id
  63. }