elb-without-ack-internal.tf 3.1 KB

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