securitygroups-load-balancers.tf 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #----------------------------------------------------------------
  2. # SG for the external ELB
  3. #----------------------------------------------------------------
  4. resource "aws_security_group" "ghe_elb_external" {
  5. name_prefix = "ghe_elb_external"
  6. tags = merge( var.standard_tags, var.tags, { Name = "github-external-lb" } )
  7. vpc_id = var.vpc_id
  8. description = "External ELB for GitHub Enterprise Server"
  9. }
  10. resource "aws_security_group_rule" "ghe_elb_external_inbound_https_22_cidr" {
  11. security_group_id = aws_security_group.ghe_elb_external.id
  12. type = "ingress"
  13. cidr_blocks = [ "0.0.0.0/0" ]
  14. from_port = 22
  15. to_port = 22
  16. protocol = "tcp"
  17. description = "Inbound git"
  18. }
  19. resource "aws_security_group_rule" "ghe_elb_external_inbound_http_cidr" {
  20. security_group_id = aws_security_group.ghe_elb_external.id
  21. type = "ingress"
  22. cidr_blocks = [ "0.0.0.0/0" ]
  23. from_port = 80
  24. to_port = 80
  25. protocol = "tcp"
  26. description = "Inbound http to ELB"
  27. }
  28. resource "aws_security_group_rule" "ghe_elb_external_inbound_https_cidr" {
  29. security_group_id = aws_security_group.ghe_elb_external.id
  30. type = "ingress"
  31. cidr_blocks = [ "0.0.0.0/0" ]
  32. from_port = 443
  33. to_port = 444
  34. protocol = "tcp"
  35. description = "Inbound https to ELB"
  36. }
  37. # Let the ELB talk to the github server(s)
  38. resource "aws_security_group_rule" "ghe_elb_external_outbound_ssh" {
  39. security_group_id = aws_security_group.ghe_elb_external.id
  40. type = "egress"
  41. source_security_group_id = aws_security_group.ghe_server.id
  42. from_port = 23
  43. to_port = 23
  44. protocol = "tcp"
  45. description = "Outbound ssh (PROXY) from ELB to GH servers"
  46. }
  47. resource "aws_security_group_rule" "ghe_elb_external_outbound_http" {
  48. security_group_id = aws_security_group.ghe_elb_external.id
  49. type = "egress"
  50. source_security_group_id = aws_security_group.ghe_server.id
  51. from_port = 80
  52. to_port = 80
  53. protocol = "tcp"
  54. description = "Outbound HTTP from ELB to GH servers for LetsEncrypt on GHE"
  55. }
  56. resource "aws_security_group_rule" "ghe_elb_external_outbound_https" {
  57. security_group_id = aws_security_group.ghe_elb_external.id
  58. type = "egress"
  59. source_security_group_id = aws_security_group.ghe_server.id
  60. from_port = 443
  61. to_port = 443
  62. protocol = "tcp"
  63. description = "Outbound https from ELB to GH servers"
  64. }
  65. #----------------------------------------------------------------
  66. # SG for the internal ELB
  67. #----------------------------------------------------------------
  68. resource "aws_security_group" "ghe_elb_internal" {
  69. name_prefix = "ghe_elb_internal"
  70. tags = merge( var.standard_tags, var.tags, { Name = "github-internal-lb" } )
  71. vpc_id = var.vpc_id
  72. description = "Internal ELB for GitHub Enterprise Server"
  73. }
  74. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_cidr" {
  75. security_group_id = aws_security_group.ghe_elb_internal.id
  76. type = "ingress"
  77. cidr_blocks = [ "10.0.0.0/8" ]
  78. from_port = 443
  79. to_port = 443
  80. protocol = "tcp"
  81. description = "Inbound https"
  82. }
  83. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_8443_cidr" {
  84. security_group_id = aws_security_group.ghe_elb_internal.id
  85. type = "ingress"
  86. cidr_blocks = [ "10.0.0.0/8" ]
  87. from_port = 8443
  88. to_port = 8443
  89. protocol = "tcp"
  90. description = "Inbound https"
  91. }
  92. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_22_cidr" {
  93. security_group_id = aws_security_group.ghe_elb_internal.id
  94. type = "ingress"
  95. cidr_blocks = [ "10.0.0.0/8" ]
  96. from_port = 22
  97. to_port = 22
  98. protocol = "tcp"
  99. description = "Inbound git"
  100. }
  101. # Let the ELB talk to the github server(s)
  102. resource "aws_security_group_rule" "ghe_elb_internal_outbound_https" {
  103. security_group_id = aws_security_group.ghe_elb_internal.id
  104. type = "egress"
  105. source_security_group_id = aws_security_group.ghe_server.id
  106. from_port = 443
  107. to_port = 443
  108. protocol = "tcp"
  109. description = "Outbound https from ELB to GH Servers"
  110. }
  111. # Let the ELB talk to the github server(s)
  112. resource "aws_security_group_rule" "ghe_elb_internal_outbound_8444_https" {
  113. security_group_id = aws_security_group.ghe_elb_internal.id
  114. type = "egress"
  115. source_security_group_id = aws_security_group.ghe_server.id
  116. from_port = 8443
  117. to_port = 8444
  118. protocol = "tcp"
  119. description = "Outbound https from ELB to GH Servers"
  120. }
  121. resource "aws_security_group_rule" "ghe_elb_internal_outbound_23_https" {
  122. security_group_id = aws_security_group.ghe_elb_internal.id
  123. type = "egress"
  124. source_security_group_id = aws_security_group.ghe_server.id
  125. from_port = 23
  126. to_port = 23
  127. protocol = "tcp"
  128. description = "Outbound https from ELB to GH Servers"
  129. }