security-groups.tf 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. endpoint_cidr_blocks = var.allow_any_to_endpoints ? [ "10.0.0.0/8" ] : [ module.vpc.vpc_cidr_block ]
  6. }
  7. module "aws_endpoints_sg" {
  8. use_name_prefix = false
  9. source = "terraform-aws-modules/security-group/aws"
  10. version = "= 4.0.0"
  11. name = "aws_endpoints"
  12. tags = merge(var.standard_tags, var.tags)
  13. vpc_id = module.vpc.vpc_id
  14. ingress_cidr_blocks = local.endpoint_cidr_blocks
  15. egress_cidr_blocks = local.endpoint_cidr_blocks
  16. egress_ipv6_cidr_blocks = [ ]
  17. egress_rules = [ "all-all" ]
  18. ingress_rules = [ "all-all" ]
  19. }
  20. # "Allow
  21. module "allow_all_from_trusted_sg" {
  22. use_name_prefix = false
  23. source = "terraform-aws-modules/security-group/aws"
  24. version = "= 4.0.0"
  25. name = "allow-all-from-trusted"
  26. tags = merge(var.standard_tags, var.tags)
  27. vpc_id = module.vpc.vpc_id
  28. ingress_cidr_blocks = concat(var.trusted_ips, [ "10.0.0.0/8" ])
  29. egress_cidr_blocks = [ "0.0.0.0/0" ]
  30. ingress_rules = [ "all-all" ]
  31. egress_rules = [ "all-all" ]
  32. }
  33. module "allow_all_outbound_sg" {
  34. use_name_prefix = false
  35. source = "terraform-aws-modules/security-group/aws"
  36. version = "= 4.0.0"
  37. name = "allow-all-outbound"
  38. tags = merge(var.standard_tags, var.tags)
  39. vpc_id = module.vpc.vpc_id
  40. egress_rules = [ "all-all" ]
  41. }
  42. module "typical_host_security_group" {
  43. source = "../../submodules/security_group/typical_host"
  44. vpc_id = module.vpc.vpc_id
  45. cidr_map = var.cidr_map
  46. tags = merge(var.standard_tags, var.tags)
  47. aws_region = var.aws_region
  48. aws_partition = var.aws_partition
  49. aws_endpoints_sg = module.aws_endpoints_sg.security_group_id
  50. }
  51. # CIS 4.3 - Default security group should restrict all traffic
  52. #
  53. # This resource is special, and clears out existing rules. See:
  54. # See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_security_group
  55. resource "aws_default_security_group" "default" {
  56. vpc_id = module.vpc.vpc_id
  57. tags = merge(var.standard_tags, var.tags)
  58. }