security-groups.tf 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #----------------------------------------------------------------------------
  2. # VPN Access Security Group
  3. #----------------------------------------------------------------------------
  4. resource "aws_security_group" "vpn_access" {
  5. # checkov:skip=CKV2_AWS_5: This SG is not an Orphan
  6. name_prefix = "${var.dns_name}${var.suffix}_vpn_access"
  7. description = "Security Group for the AWS VPN"
  8. vpc_id = var.vpc_id
  9. tags = merge(local.standard_tags, var.tags)
  10. }
  11. #----------------------------------------------------------------------------
  12. # INGRESS
  13. #----------------------------------------------------------------------------
  14. resource "aws_security_group_rule" "vpn-in-443-tcp" {
  15. type = "ingress"
  16. description = "443 - TCP - Inbound"
  17. from_port = 443
  18. to_port = 443
  19. protocol = "tcp"
  20. cidr_blocks = ["0.0.0.0/0"] # tfsec:ignore:aws-vpc-no-public-ingress-sgr
  21. security_group_id = aws_security_group.vpn_access.id
  22. }
  23. resource "aws_security_group_rule" "vpn-in-443-udp" {
  24. type = "ingress"
  25. description = "443 - UDP - Inbound"
  26. from_port = 443
  27. to_port = 443
  28. protocol = "udp"
  29. cidr_blocks = ["0.0.0.0/0"] # tfsec:ignore:aws-vpc-no-public-ingress-sgr
  30. security_group_id = aws_security_group.vpn_access.id
  31. }
  32. resource "aws_security_group_rule" "vpn-in-1194-tcp" {
  33. type = "ingress"
  34. description = "1194 - TCP - Inbound"
  35. from_port = 1194
  36. to_port = 1194
  37. protocol = "tcp"
  38. cidr_blocks = ["0.0.0.0/0"] # tfsec:ignore:aws-vpc-no-public-ingress-sgr
  39. security_group_id = aws_security_group.vpn_access.id
  40. }
  41. resource "aws_security_group_rule" "vpn-in-1194-udp" {
  42. type = "ingress"
  43. description = "1194 - UDP - Inbound"
  44. from_port = 1194
  45. to_port = 1194
  46. protocol = "udp"
  47. cidr_blocks = ["0.0.0.0/0"] # tfsec:ignore:aws-vpc-no-public-ingress-sgr
  48. security_group_id = aws_security_group.vpn_access.id
  49. }
  50. #----------------------------------------------------------------------------
  51. # EGRESS
  52. #----------------------------------------------------------------------------
  53. resource "aws_security_group_rule" "vpn-out" {
  54. type = "egress"
  55. description = "VPN - Outbound"
  56. from_port = -1
  57. to_port = -1
  58. protocol = -1
  59. cidr_blocks = ["0.0.0.0/0"] # tfsec:ignore:aws-vpc-no-public-egress-sgr
  60. security_group_id = aws_security_group.vpn_access.id
  61. }