nlb-for-hec.tf 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # An NLB to allow for a static IP on the hec
  2. #########################
  3. # DNS Entry
  4. module "public_dns_record_hec_static" {
  5. source = "../../../submodules/dns/public_ALIAS_record"
  6. name = "${var.prefix}-hec"
  7. target_dns_name = aws_lb.hec_static.dns_name
  8. target_zone_id = aws_lb.hec_static.zone_id
  9. dns_info = var.dns_info
  10. providers = {
  11. aws.mdr-common-services-commercial = aws.mdr-common-services-commercial
  12. }
  13. }
  14. #########################
  15. # EIP
  16. resource "aws_eip" "hec_static" {
  17. count = 2
  18. vpc = true
  19. tags = merge(var.standard_tags, var.tags)
  20. }
  21. #########################
  22. # ELB
  23. resource "aws_lb" "hec_static" {
  24. tags = merge(var.standard_tags, var.tags)
  25. name = "${var.prefix}-hec-static"
  26. load_balancer_type = "network"
  27. internal = false # tfsec:ignore:aws-elb-alb-not-public LB is intentionally public
  28. subnet_mapping {
  29. subnet_id = var.public_subnets[0]
  30. allocation_id = aws_eip.hec_static[0].id
  31. }
  32. subnet_mapping {
  33. subnet_id = var.public_subnets[1]
  34. allocation_id = aws_eip.hec_static[1].id
  35. }
  36. # Access logs are a feedback loop. They create logs that are then sent back through the HEC.
  37. # They should remain disabled.
  38. #access_logs {
  39. # bucket = "xdr-elb-${ var.environment }"
  40. # enabled = true
  41. #}
  42. }
  43. #resource "aws_lb_listener" "front_end" {
  44. # load_balancer_arn = aws_lb.front_end.arn
  45. # port = "443"
  46. # protocol = "TLS"
  47. # certificate_arn = "arn:aws:iam::187416307283:server-certificate/test_cert_rab3wuqwgja25ct3n4jdj2tzu4"
  48. # alpn_policy = "HTTP2Preferred"
  49. #
  50. # default_action {
  51. # type = "forward"
  52. # target_group_arn = aws_lb_target_group.front_end.arn
  53. # }
  54. #}
  55. resource "aws_lb_listener" "hec_static_443" {
  56. count = anytrue([local.is_moose, var.hec_listen_443]) ? 1 : 0
  57. load_balancer_arn = aws_lb.hec_static.arn
  58. port = 443
  59. protocol = "TCP"
  60. default_action {
  61. type = "forward"
  62. target_group_arn = aws_lb_target_group.hec_static_8088.arn
  63. }
  64. }
  65. resource "aws_lb_listener" "hec_static_8088" {
  66. load_balancer_arn = aws_lb.hec_static.arn
  67. port = 8088
  68. protocol = "TCP"
  69. default_action {
  70. type = "forward"
  71. target_group_arn = aws_lb_target_group.hec_static_8088.arn
  72. }
  73. }
  74. resource "aws_lb_target_group" "hec_static_8088" {
  75. name = "${var.prefix}-hec-static-targets"
  76. port = 8088
  77. protocol = "TCP"
  78. target_type = "alb"
  79. vpc_id = var.vpc_id
  80. # health_chec_static {
  81. # path = "/services/collector/health/1.0"
  82. # protocol = "HTTPS"
  83. # }
  84. }
  85. resource "aws_lb_target_group_attachment" "hec_static" {
  86. target_group_arn = aws_lb_target_group.hec_static_8088.arn
  87. target_id = aws_lb.hec.id
  88. port = 8088
  89. }