elbclassic.tf 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. module "public_dns_record" {
  2. source = "../../submodules/dns/public_ALIAS_record"
  3. name = "github.${var.dns_info["public"]["zone"]}"
  4. target_dns_name = aws_elb.external.dns_name
  5. target_zone_id = aws_elb.external.zone_id
  6. dns_info = var.dns_info
  7. providers = {
  8. aws.mdr-common-services-commercial = aws.mdr-common-services-commercial
  9. }
  10. }
  11. module "public_dns_record_wildcard" {
  12. source = "../../submodules/dns/public_ALIAS_record"
  13. name = "*.github.${var.dns_info["public"]["zone"]}"
  14. target_dns_name = aws_elb.external.dns_name
  15. target_zone_id = aws_elb.external.zone_id
  16. dns_info = var.dns_info
  17. providers = {
  18. aws.mdr-common-services-commercial = aws.mdr-common-services-commercial
  19. }
  20. }
  21. # If ever this gets converted to an ALB, consider adding the waf module.
  22. resource "aws_elb" "external" {
  23. name_prefix = "gheext"
  24. subnets = var.public_subnets
  25. security_groups = [ aws_security_group.ghe_elb_external.id ]
  26. listener {
  27. instance_port = 443
  28. instance_protocol = "HTTPS"
  29. lb_port = 443
  30. lb_protocol = "HTTPS"
  31. ssl_certificate_id = aws_acm_certificate.cert_public.arn
  32. }
  33. listener {
  34. instance_port = 80
  35. instance_protocol = "HTTP"
  36. lb_port = 80
  37. lb_protocol = "HTTP"
  38. }
  39. listener {
  40. instance_port = 23
  41. instance_protocol = "TCP"
  42. lb_port = 22
  43. lb_protocol = "TCP"
  44. }
  45. health_check {
  46. healthy_threshold = 2
  47. unhealthy_threshold = 2
  48. timeout = 3
  49. target = "HTTPS:443/status"
  50. interval = 30
  51. }
  52. }
  53. resource "aws_proxy_protocol_policy" "external_proxy_protocol" {
  54. load_balancer = aws_elb.external.name
  55. instance_ports = [ "23", "444" ]
  56. }
  57. # Create a new load balancer attachment
  58. resource "aws_elb_attachment" "external_attachment" {
  59. count = var.instance_count
  60. elb = aws_elb.external.id
  61. instance = aws_instance.ghe[count.index].id
  62. }
  63. #--------------------------------------------------------------
  64. # Internal ELB
  65. #--------------------------------------------------------------
  66. resource "aws_route53_record" "github_internal" {
  67. zone_id = var.dns_info["private"]["zone_id"]
  68. name = "github.${var.dns_info["private"]["zone"]}"
  69. type = "CNAME"
  70. records = [aws_elb.internal.dns_name]
  71. ttl = "60"
  72. provider = aws.c2
  73. }
  74. resource "aws_route53_record" "github_internal_wildcard" {
  75. zone_id = var.dns_info["private"]["zone_id"]
  76. name = "*.github.${var.dns_info["private"]["zone"]}"
  77. type = "CNAME"
  78. records = [aws_elb.internal.dns_name]
  79. ttl = "60"
  80. provider = aws.c2
  81. }
  82. resource "aws_elb" "internal" {
  83. name_prefix = "gheint"
  84. internal = true
  85. subnets = var.private_subnets
  86. security_groups = [ aws_security_group.ghe_elb_internal.id ]
  87. listener {
  88. instance_port = 443
  89. instance_protocol = "HTTPS"
  90. lb_port = 443
  91. lb_protocol = "HTTPS"
  92. ssl_certificate_id = aws_acm_certificate.cert.arn
  93. }
  94. listener {
  95. instance_port = 8444
  96. instance_protocol = "TCP"
  97. lb_port = 8443
  98. lb_protocol = "TCP"
  99. }
  100. listener {
  101. instance_port = 23
  102. instance_protocol = "TCP"
  103. lb_port = 22
  104. lb_protocol = "TCP"
  105. }
  106. health_check {
  107. healthy_threshold = 2
  108. unhealthy_threshold = 2
  109. timeout = 3
  110. target = "HTTPS:443/status"
  111. interval = 30
  112. }
  113. }
  114. resource "aws_proxy_protocol_policy" "internal_proxy_protocol" {
  115. load_balancer = aws_elb.internal.name
  116. instance_ports = [ "23", "444", "8444"]
  117. }
  118. # Create a new load balancer attachment
  119. resource "aws_elb_attachment" "internal_attachment" {
  120. count = var.instance_count
  121. elb = aws_elb.internal.id
  122. instance = aws_instance.ghe[count.index].id
  123. }