You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5 KiB

  1. resource "aws_security_group" "aws-elb" {
  2. name = "kubernetes-${var.aws_cluster_name}-securitygroup-elb"
  3. vpc_id = "${var.aws_vpc_id}"
  4. tags = "${merge(var.default_tags, map(
  5. "Name", "kubernetes-${var.aws_cluster_name}-securitygroup-elb"
  6. ))}"
  7. }
  8. resource "aws_security_group_rule" "aws-allow-api-access" {
  9. type = "ingress"
  10. from_port = "${var.aws_elb_api_port}"
  11. to_port = "${var.k8s_secure_api_port}"
  12. protocol = "TCP"
  13. cidr_blocks = ["0.0.0.0/0"]
  14. security_group_id = "${aws_security_group.aws-elb.id}"
  15. }
  16. resource "aws_security_group_rule" "aws-allow-api-egress" {
  17. type = "egress"
  18. from_port = 0
  19. to_port = 65535
  20. protocol = "TCP"
  21. cidr_blocks = ["0.0.0.0/0"]
  22. security_group_id = "${aws_security_group.aws-elb.id}"
  23. }
  24. # Create a new AWS ELB for K8S API
  25. resource "aws_elb" "aws-elb-api" {
  26. name = "kubernetes-elb-${var.aws_cluster_name}"
  27. subnets = ["${var.aws_subnet_ids_public}"]
  28. security_groups = ["${aws_security_group.aws-elb.id}"]
  29. listener {
  30. instance_port = "${var.k8s_secure_api_port}"
  31. instance_protocol = "tcp"
  32. lb_port = "${var.aws_elb_api_port}"
  33. lb_protocol = "tcp"
  34. }
  35. health_check {
  36. healthy_threshold = 2
  37. unhealthy_threshold = 2
  38. timeout = 3
  39. target = "TCP:${var.k8s_secure_api_port}"
  40. interval = 30
  41. }
  42. cross_zone_load_balancing = true
  43. idle_timeout = 400
  44. connection_draining = true
  45. connection_draining_timeout = 400
  46. tags = "${merge(var.default_tags, map(
  47. "Name", "kubernetes-${var.aws_cluster_name}-elb-api"
  48. ))}"
  49. }