typicalhost.tf.disabled 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. # TODO: We probably want this in this module as a standard group in all VPCs, but disabling
  2. # for now due to complexity.
  3. #
  4. # For a "typical host" we have some simple expectations
  5. # - able to talk to one of the various salt masters
  6. # - able to talk to Amazon's DNS servers
  7. # - allow inbound SSH from bastion
  8. # - any outbound RPM repo access needed
  9. # - 9998/tcp to moose indexers
  10. #
  11. #
  12. # The following is a little complicated because the mainline security-group module
  13. # is lacking a little in being able to be super expressive w/ rules. So we
  14. # create the base SG with the module, and then attach more detailed rules to it when
  15. # complete
  16. module "typical_host_sg" {
  17. use_name_prefix = false
  18. source = "terraform-aws-modules/security-group/aws"
  19. version = "~> 2.17"
  20. name = "typical-host"
  21. tags = "${local.standard_tags}"
  22. vpc_id = "${module.vpc.vpc_id}"
  23. ingress_cidr_blocks = [ "10.0.0.0/8" ]
  24. ingress_rules = [ "all-icmp" ]
  25. egress_ipv6_cidr_blocks = [ ]
  26. egress_with_cidr_blocks = [
  27. {
  28. description = "TCP DNS to Amazon VPC DNS Server"
  29. rule = "dns-tcp"
  30. cidr_blocks = "${cidrhost(module.vpc.vpc_cidr_block,2)}/32"
  31. },
  32. {
  33. description = "UDP DNS to Amazon VPC DNS Server"
  34. rule = "dns-udp"
  35. cidr_blocks = "${cidrhost(module.vpc.vpc_cidr_block,2)}/32"
  36. },
  37. {
  38. description = "ICMP"
  39. rule = "all-icmp"
  40. cidr_blocks = "10.0.0.0/8"
  41. },
  42. ]
  43. #egress_with_ipv6_cidr_blocks = [
  44. # {
  45. # description = "Saltstack RPM Repos IPv6"
  46. # rule = "https-443-tcp"
  47. # ipv6_cidr_blocks = "2604:a880:400:d0::2:e001/128"
  48. # }
  49. #]
  50. }
  51. resource "aws_security_group_rule" "outbound_to_salt_masters"
  52. {
  53. type = "egress"
  54. from_port = 4505
  55. to_port = 4506
  56. protocol = 6
  57. source_security_group_id = "${module.salt_masters_sg.this_security_group_id}"
  58. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  59. description = "Connect to Salt Masters"
  60. }
  61. resource "aws_security_group_rule" "outbound_to_repo_servers_80"
  62. {
  63. type = "egress"
  64. from_port = 80
  65. to_port = 80
  66. protocol = 6
  67. source_security_group_id = "${module.repo_servers_sg.this_security_group_id}"
  68. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  69. description = "Connect to Repo Servers"
  70. }
  71. resource "aws_security_group_rule" "inbound_ssh_bastion"
  72. {
  73. type = "ingress"
  74. from_port = 22
  75. to_port = 22
  76. protocol = 6
  77. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  78. source_security_group_id = "${module.bastion_servers_sg.this_security_group_id}"
  79. #cidr_blocks = [ "${formatlist("%s/32",module.bastion.private_ip)}" ]
  80. description = "Inbound SSH from bastions"
  81. }
  82. resource "aws_security_group_rule" "typical_host_inbound_ssh_openvpn"
  83. {
  84. type = "ingress"
  85. from_port = 22
  86. to_port = 22
  87. protocol = 6
  88. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  89. source_security_group_id = "${module.openvpn_servers_sg.this_security_group_id}"
  90. description = "Inbound SSH from openvpn"
  91. }
  92. resource "aws_security_group_rule" "outbound_to_ec2_endpoints"
  93. {
  94. type = "egress"
  95. from_port = 0
  96. to_port = 0
  97. protocol = -1
  98. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  99. source_security_group_id = "${module.aws_endpoints_sg.this_security_group_id}"
  100. description = "Outbound to EC2 endpoints"
  101. }
  102. resource "aws_security_group_rule" "outbound_to_ec2_s3_endpoint"
  103. {
  104. type = "egress"
  105. from_port = 0
  106. to_port = 0
  107. protocol = -1
  108. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  109. prefix_list_ids = [ "${module.vpc.vpc_endpoint_s3_pl_id}" ]
  110. description = "Outbound to S3 endpoint"
  111. }
  112. resource "aws_security_group_rule" "outbound_to_squid_http"
  113. {
  114. type = "egress"
  115. from_port = 80
  116. to_port = 80
  117. protocol = 6
  118. source_security_group_id = "${module.proxy_servers_sg.this_security_group_id}"
  119. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  120. description = "HTTPS outbound to proxies"
  121. }
  122. resource "aws_security_group_rule" "outbound_to_mailrelay_25"
  123. {
  124. type = "egress"
  125. from_port = 25
  126. to_port = 25
  127. protocol = 6
  128. source_security_group_id = "${module.mailrelay_sg.this_security_group_id}"
  129. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  130. description = "Outbound Email to mailrelay"
  131. }
  132. resource "aws_security_group_rule" "outbound_to_sensu"
  133. {
  134. type = "egress"
  135. from_port = 8081
  136. to_port = 8081
  137. protocol = "tcp"
  138. source_security_group_id = "${module.sensu_servers_sg.this_security_group_id}"
  139. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  140. description = "Sensu Outbound"
  141. }
  142. resource "aws_security_group_rule" "outbound_to_moose_s2s"
  143. {
  144. type = "egress"
  145. from_port = 9997
  146. to_port = 9998
  147. protocol = "tcp"
  148. #cidr_blocks = [ "${module.vpc.vpc_cidr_block}" ]
  149. source_security_group_id = "${module.moose_inbound_sg.this_security_group_id}"
  150. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  151. description = "Splunk UF outbound to Moose Indexers"
  152. }
  153. resource "aws_security_group_rule" "outbound_to_moose_idxc"
  154. {
  155. type = "egress"
  156. from_port = 8089
  157. to_port = 8089
  158. protocol = "tcp"
  159. #cidr_blocks = [ "${module.vpc.vpc_cidr_block}" ]
  160. source_security_group_id = "${module.moose_inbound_sg.this_security_group_id}"
  161. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  162. description = "Outbound IDXC Discovery to MOOSE"
  163. }
  164. resource "aws_security_group_rule" "outbound_to_moose_hec"
  165. {
  166. type = "egress"
  167. from_port = 8088
  168. to_port = 8088
  169. protocol = 6
  170. source_security_group_id = "${module.moose_inbound_sg.this_security_group_id}"
  171. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  172. description = "Connect to HEC"
  173. }
  174. resource "aws_security_group_rule" "inbound_from_vuln_scanners"
  175. {
  176. type = "ingress"
  177. from_port = -1
  178. to_port = -1
  179. protocol = -1
  180. source_security_group_id = "${module.vuln_scanners_sg.this_security_group_id}"
  181. security_group_id = "${module.typical_host_sg.this_security_group_id}"
  182. description = "Allow all from Vuln Scanners"
  183. }