securitygroups-load-balancers.tf 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_https_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 = 443
  24. to_port = 444
  25. protocol = "tcp"
  26. description = "Inbound https to ELB"
  27. }
  28. # Let the ELB talk to the github server(s)
  29. resource "aws_security_group_rule" "ghe_elb_external_outbound_ssh" {
  30. security_group_id = aws_security_group.ghe_elb_external.id
  31. type = "egress"
  32. source_security_group_id = aws_security_group.ghe_server.id
  33. from_port = 23
  34. to_port = 23
  35. protocol = "tcp"
  36. description = "Outbound ssh (PROXY) from ELB to GH servers"
  37. }
  38. resource "aws_security_group_rule" "ghe_elb_external_outbound_https" {
  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 = 443
  43. to_port = 443
  44. protocol = "tcp"
  45. description = "Outbound https from ELB to GH servers"
  46. }
  47. #----------------------------------------------------------------
  48. # SG for the internal ELB
  49. #----------------------------------------------------------------
  50. resource "aws_security_group" "ghe_elb_internal" {
  51. name_prefix = "ghe_elb_internal"
  52. tags = merge( var.standard_tags, var.tags, { Name = "github-internal-lb" } )
  53. vpc_id = var.vpc_id
  54. description = "Internal ELB for GitHub Enterprise Server"
  55. }
  56. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_cidr" {
  57. security_group_id = aws_security_group.ghe_elb_internal.id
  58. type = "ingress"
  59. cidr_blocks = [ "10.0.0.0/8" ]
  60. from_port = 443
  61. to_port = 443
  62. protocol = "tcp"
  63. description = "Inbound https"
  64. }
  65. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_8443_cidr" {
  66. security_group_id = aws_security_group.ghe_elb_internal.id
  67. type = "ingress"
  68. cidr_blocks = [ "10.0.0.0/8" ]
  69. from_port = 8443
  70. to_port = 8443
  71. protocol = "tcp"
  72. description = "Inbound https"
  73. }
  74. resource "aws_security_group_rule" "ghe_elb_internal_inbound_https_22_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 = 22
  79. to_port = 22
  80. protocol = "tcp"
  81. description = "Inbound git"
  82. }
  83. # Let the ELB talk to the github server(s)
  84. resource "aws_security_group_rule" "ghe_elb_internal_outbound_https" {
  85. security_group_id = aws_security_group.ghe_elb_internal.id
  86. type = "egress"
  87. source_security_group_id = aws_security_group.ghe_server.id
  88. from_port = 443
  89. to_port = 443
  90. protocol = "tcp"
  91. description = "Outbound https from ELB to GH Servers"
  92. }
  93. # Let the ELB talk to the github server(s)
  94. resource "aws_security_group_rule" "ghe_elb_internal_outbound_8444_https" {
  95. security_group_id = aws_security_group.ghe_elb_internal.id
  96. type = "egress"
  97. source_security_group_id = aws_security_group.ghe_server.id
  98. from_port = 8443
  99. to_port = 8443
  100. protocol = "tcp"
  101. description = "Outbound https from ELB to GH Servers"
  102. }
  103. resource "aws_security_group_rule" "ghe_elb_internal_outbound_23_https" {
  104. security_group_id = aws_security_group.ghe_elb_internal.id
  105. type = "egress"
  106. source_security_group_id = aws_security_group.ghe_server.id
  107. from_port = 23
  108. to_port = 23
  109. protocol = "tcp"
  110. description = "Outbound https from ELB to GH Servers"
  111. }