elb-without-ack-internal.tf 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #------------------------------------------------------------------------------
  2. # An internal ALB without ACKs for moose only
  3. #------------------------------------------------------------------------------
  4. #########################
  5. # DNS Entry
  6. #resource "aws_route53_record" "hec_internal" {
  7. # count = local.is_moose ? 1 : 0
  8. # name = "iratemoses"
  9. # type = "CNAME"
  10. # zone_id = var.dns_info["legacy_private"]["zone_id"]
  11. # ttl = "600"
  12. # records = [ aws_lb.hec_internal[count.index].dns_name ]
  13. #
  14. # provider = aws.legacy
  15. #}
  16. resource "aws_route53_record" "hec_internal_accenturefederalcyber" {
  17. count = local.is_moose ? 1 : 0
  18. name = "iratemoses"
  19. type = "CNAME"
  20. zone_id = var.dns_info["private"]["zone_id"]
  21. ttl = "600"
  22. records = [aws_lb.hec_internal[count.index].dns_name]
  23. provider = aws.c2
  24. }
  25. #output hec-without-acks-internal-fqdn {
  26. # value = local.is_moose ? aws_route53_record.hec_internal[0].fqdn : "<not created for non-moose>"
  27. #}
  28. output "hec-without-acks-internal-records" {
  29. value = local.is_moose ? aws_lb.hec_internal[0].dns_name : "<not created for non-moose>"
  30. }
  31. #########################
  32. # Certificate
  33. # We use the public one
  34. #########################
  35. # ELB
  36. resource "aws_lb" "hec_internal" {
  37. count = local.is_moose ? 1 : 0
  38. tags = merge(local.standard_tags, var.tags)
  39. name = "iratemoses"
  40. load_balancer_type = "application"
  41. security_groups = [data.aws_security_group.hec_internal_elb_security_group[0].id]
  42. subnets = var.private_subnets
  43. internal = true
  44. drop_invalid_header_fields = true
  45. }
  46. resource "aws_lb_listener" "hec_internal_443" {
  47. count = local.is_moose ? 1 : 0
  48. load_balancer_arn = aws_lb.hec_internal[count.index].arn
  49. port = 443
  50. protocol = "HTTPS"
  51. ssl_policy = "ELBSecurityPolicy-FS-1-2-Res-2020-10" # PFS, TLS1.2, and GCM; most "restrictive" policy
  52. certificate_arn = aws_acm_certificate.hec_cert.arn # Intentionally using the external cert
  53. default_action {
  54. type = "forward"
  55. target_group_arn = aws_lb_target_group.hec_internal_8088[count.index].arn
  56. }
  57. }
  58. resource "aws_lb_listener" "hec_internal_8088" {
  59. count = local.is_moose ? 1 : 0
  60. load_balancer_arn = aws_lb.hec_internal[count.index].arn
  61. port = 8088
  62. protocol = "HTTPS"
  63. ssl_policy = "ELBSecurityPolicy-FS-1-2-Res-2020-10" # PFS, TLS1.2, and GCM; most "restrictive" policy
  64. certificate_arn = aws_acm_certificate.hec_cert.arn # Intentionally using the external cert
  65. default_action {
  66. type = "forward"
  67. target_group_arn = aws_lb_target_group.hec_internal_8088[count.index].arn
  68. }
  69. }
  70. resource "aws_lb_target_group" "hec_internal_8088" {
  71. count = local.is_moose ? 1 : 0
  72. name = "${var.prefix}-legacy-hec-int-tgts"
  73. port = 8088
  74. protocol = "HTTPS"
  75. target_type = "instance"
  76. vpc_id = var.vpc_id
  77. health_check {
  78. path = "/services/collector/health/1.0"
  79. protocol = "HTTPS"
  80. }
  81. }
  82. # Attach the instances to the ELB
  83. resource "aws_autoscaling_attachment" "hec_internal_asg_attachments" {
  84. for_each = local.is_moose ? toset(var.elb_attachments) : []
  85. lb_target_group_arn = aws_lb_target_group.hec_internal_8088[0].arn
  86. autoscaling_group_name = each.key
  87. }