cluster_sg.tf 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. Security Groups and Rules for Cluster.
  3. Note: Please see our Production Guide for network security
  4. recommendations.
  5. https://gravitational.com/teleport/docs/production/#firewall-configuration
  6. */
  7. // Create a Security Group
  8. resource "aws_security_group" "cluster" {
  9. name = "${var.cluster_name}-cluster"
  10. vpc_id = data.aws_vpc.default.id
  11. tags = {
  12. TeleportCluster = var.cluster_name
  13. }
  14. }
  15. // Permit inbound to SSH
  16. resource "aws_security_group_rule" "cluster_ingress_ssh" {
  17. type = "ingress"
  18. from_port = 22
  19. to_port = 22
  20. protocol = "tcp"
  21. cidr_blocks = ["0.0.0.0/0"]
  22. security_group_id = aws_security_group.cluster.id
  23. }
  24. // Permit inbound to Teleport Web interface
  25. resource "aws_security_group_rule" "cluster_ingress_web" {
  26. type = "ingress"
  27. from_port = 3080
  28. to_port = 3080
  29. protocol = "tcp"
  30. cidr_blocks = ["0.0.0.0/0"]
  31. security_group_id = aws_security_group.cluster.id
  32. }
  33. // Permit inbound to Teleport services
  34. resource "aws_security_group_rule" "cluster_ingress_services" {
  35. type = "ingress"
  36. from_port = 3022
  37. to_port = 3025
  38. protocol = "tcp"
  39. cidr_blocks = ["0.0.0.0/0"]
  40. security_group_id = aws_security_group.cluster.id
  41. }
  42. // Permit all outbound traffic
  43. resource "aws_security_group_rule" "cluster_egress" {
  44. type = "egress"
  45. from_port = 0
  46. to_port = 0
  47. protocol = "-1"
  48. cidr_blocks = ["0.0.0.0/0"]
  49. security_group_id = aws_security_group.cluster.id
  50. }