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. #
  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(var.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. }
  45. resource "aws_lb_listener" "hec_internal_443" {
  46. count = local.is_moose ? 1 : 0
  47. load_balancer_arn = aws_lb.hec_internal[count.index].arn
  48. port = 443
  49. protocol = "HTTPS"
  50. ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01"
  51. certificate_arn = aws_acm_certificate.hec_cert.arn # Intentionally using the external cert
  52. default_action {
  53. type = "forward"
  54. target_group_arn = aws_lb_target_group.hec_internal_8088[count.index].arn
  55. }
  56. }
  57. resource "aws_lb_listener" "hec_internal_8088" {
  58. count = local.is_moose ? 1 : 0
  59. load_balancer_arn = aws_lb.hec_internal[count.index].arn
  60. port = 8088
  61. protocol = "HTTPS"
  62. ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01"
  63. certificate_arn = aws_acm_certificate.hec_cert.arn # Intentionally using the external cert
  64. default_action {
  65. type = "forward"
  66. target_group_arn = aws_lb_target_group.hec_internal_8088[count.index].arn
  67. }
  68. }
  69. resource "aws_lb_target_group" "hec_internal_8088" {
  70. count = local.is_moose ? 1 : 0
  71. name = "${var.prefix}-legacy-hec-int-tgts"
  72. port = 8088
  73. protocol = "HTTPS"
  74. target_type = "instance"
  75. vpc_id = var.vpc_id
  76. health_check {
  77. path = "/services/collector/health/1.0"
  78. protocol = "HTTPS"
  79. }
  80. }
  81. # Attach the instances to the ELB
  82. resource "aws_autoscaling_attachment" "hec_internal_asg_attachments" {
  83. for_each = local.is_moose ? toset( var.elb_attachments ) : []
  84. alb_target_group_arn = aws_lb_target_group.hec_internal_8088[0].arn
  85. autoscaling_group_name = each.key
  86. }