security-groups.tf 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Several of these security groups will have customer IPs listed in them to allow
  2. # POP systems to access our services.
  3. #
  4. locals {
  5. }
  6. module "aws_endpoints_sg" {
  7. use_name_prefix = false
  8. source = "terraform-aws-modules/security-group/aws"
  9. version = "~> 3"
  10. name = "aws_endpoints"
  11. tags = merge(var.standard_tags, var.tags)
  12. vpc_id = module.vpc.vpc_id
  13. ingress_cidr_blocks = [ module.vpc.vpc_cidr_block ]
  14. egress_cidr_blocks = [ module.vpc.vpc_cidr_block ]
  15. egress_ipv6_cidr_blocks = [ ]
  16. egress_rules = [ "all-all" ]
  17. ingress_rules = [ "all-all" ]
  18. }
  19. #TODO: Probably want this one available everywhere
  20. #module "vpc_default_security_groups" {
  21. # source = "../modules/vpc_security_groups"
  22. # version = "~> 2.17"
  23. # name = "toolsvpc"
  24. # tags = merge(var.standard_tags, var.tags)
  25. # this_vpc = "${module.vpc.vpc_id}"
  26. #
  27. # ec2_prefix_list_count = 1
  28. # ec2_prefix_lists = [ "${module.vpc.vpc_endpoint_s3_pl_id}" ]
  29. # salt_masters_sg = "${module.salt_masters_sg.this_security_group_id}"
  30. # bastion_ssh_sg = "${module.bastion_servers_sg.this_security_group_id}"
  31. # proxy_servers_sg = "${module.proxy_servers_sg.this_security_group_id}"
  32. # sensu_servers_sg = "${module.sensu_servers_sg.this_security_group_id}"
  33. # repo_servers_sg = "${module.repo_servers_sg.this_security_group_id}"
  34. # idm_inbound_sg = "${module.idm_inbound_sg.this_security_group_id}"
  35. # openvpn_servers_sg = "${module.openvpn_servers_sg.this_security_group_id}"
  36. # phantom_servers_sg = "${module.phantom_servers_sg.this_security_group_id}"
  37. # mailrelay_sg = "${module.mailrelay_sg.this_security_group_id}"
  38. # moose_sg = "${module.moose_inbound_sg.this_security_group_id}"
  39. # vuln_scanner_sg_count = 1
  40. # vuln_scanner_sgs = [ "${module.vuln_scanners_sg.this_security_group_id}" ]
  41. #}
  42. # "Allow
  43. module "allow_all_from_trusted_sg" {
  44. use_name_prefix = false
  45. source = "terraform-aws-modules/security-group/aws"
  46. version = "~> 3"
  47. name = "allow-all-from-trusted"
  48. tags = merge(var.standard_tags, var.tags)
  49. vpc_id = module.vpc.vpc_id
  50. ingress_cidr_blocks = concat(var.trusted_ips, [ "10.0.0.0/8" ])
  51. egress_cidr_blocks = [ "0.0.0.0/0" ]
  52. ingress_rules = [ "all-all" ]
  53. egress_rules = [ "all-all" ]
  54. }
  55. module "allow_all_outbound_sg" {
  56. use_name_prefix = false
  57. source = "terraform-aws-modules/security-group/aws"
  58. version = "~> 3"
  59. name = "allow-all-outbound"
  60. tags = merge(var.standard_tags, var.tags)
  61. vpc_id = module.vpc.vpc_id
  62. egress_rules = [ "all-all" ]
  63. }
  64. # TODO: Do we still want direct ssh as a standard SG? I think we want
  65. # to avoid this, so I'd say create it only with resources that need it.
  66. #module "ssh_all_sg" {
  67. # use_name_prefix = false
  68. # source = "terraform-aws-modules/security-group/aws"
  69. # version = "~> 2.17"
  70. # name = "ssh-any"
  71. # tags = merge(var.standard_tags, var.tags)
  72. # vpc_id = "${module.vpc.vpc_id}"
  73. #
  74. # ingress_cidr_blocks = "${local.ssh_jump_whitelist}"
  75. #
  76. # egress_cidr_blocks = [ "0.0.0.0/0" ]
  77. # ingress_rules = [ "ssh-tcp", "all-icmp" ]
  78. #}
  79. module "typical_host_security_group" {
  80. source = "../../submodules/security_group/typical_host"
  81. vpc_id = module.vpc.vpc_id
  82. cidr_map = var.cidr_map
  83. tags = merge(var.standard_tags, var.tags)
  84. aws_region = var.aws_region
  85. aws_partition = var.aws_partition
  86. }
  87. # CIS 4.3 - Default security group should restrict all traffic
  88. #
  89. # This resource is special, and clears out existing rules. See:
  90. # See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_security_group
  91. resource "aws_default_security_group" "default" {
  92. vpc_id = module.vpc.vpc_id
  93. tags = merge(var.standard_tags, var.tags)
  94. }