security-groups.tf 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Rather than pass in the aws security group, we just look it up. This will
  2. # probably be useful other places, as well.
  3. data "aws_security_group" "typical-host" {
  4. name = "typical-host"
  5. vpc_id = var.vpc_id
  6. }
  7. resource "aws_security_group" "instance" {
  8. name = "instance-${var.instance_name}"
  9. description = "Instances of type ${var.instance_name}"
  10. vpc_id = var.vpc_id
  11. tags = merge(var.standard_tags, var.tags)
  12. }
  13. resource "aws_security_group_rule" "instance-http-in" {
  14. description = "HTTP in - used for letsencrypt certbot"
  15. type = "ingress"
  16. from_port = "80"
  17. to_port = "80"
  18. protocol = "tcp"
  19. cidr_blocks = [ "0.0.0.0/0" ]
  20. security_group_id = aws_security_group.instance.id
  21. }
  22. resource "aws_security_group_rule" "instance-teleport-in" {
  23. description = "Teleport"
  24. type = "ingress"
  25. from_port = "3023"
  26. to_port = "3025"
  27. protocol = "tcp"
  28. cidr_blocks = [ "10.0.0.0/8" ]
  29. security_group_id = aws_security_group.instance.id
  30. }
  31. resource "aws_security_group_rule" "instance-teleport-proxy-in" {
  32. description = "Teleport - Proxy web server"
  33. type = "ingress"
  34. from_port = "3080"
  35. to_port = "3080"
  36. protocol = "tcp"
  37. cidr_blocks = [ "0.0.0.0/0" ]
  38. security_group_id = aws_security_group.instance.id
  39. }