security-groups.tf 2.5 KB

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