resource "aws_alb_target_group" "tg-spot-kr-tcp-30000" {
    name      = "tg-spot-kr-tcp-30000"
    port      = 30000
    protocol  = "TCP"
    vpc_id    = "${var.VPC_ID}"

    health_check {
        interval            = 30
        protocol            = "TCP"
        healthy_threshold   = 3
        unhealthy_threshold = 3
    }

}

resource "aws_alb_target_group_attachment" "spot-master-http-2a" {
  target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30000.arn}"
  target_id        = "${var.master-2a}"
  port             = 30000
}

resource "aws_alb_target_group_attachment" "spot-master-http-2b" {
  target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30000.arn}"
  target_id        = "${var.master-2b}"
  port             = 30000
}

resource "aws_alb_target_group_attachment" "spot-master-http-2c" {
  target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30000.arn}"
  target_id        = "${var.master-2c}"
  port             = 30000
}

###############################################################################

resource "aws_alb_target_group" "tg-spot-kr-tcp-30001" {
    name      = "tg-spot-kr-tcp-30001"
    port      = 30001
    protocol  = "TCP"
    vpc_id    = "${var.VPC_ID}"

    health_check {
        interval            = 30
        protocol            = "TCP"
        healthy_threshold   = 3
        unhealthy_threshold = 3
    }

}

resource "aws_alb_target_group_attachment" "spot-master-tls-2a" {
  target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30001.arn}"
  target_id        = "${var.master-2a}"
  port             = 30001
}

resource "aws_alb_target_group_attachment" "spot-master-tls-2b" {
  target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30001.arn}"
  target_id        = "${var.master-2b}"
  port             = 30001
}

resource "aws_alb_target_group_attachment" "spot-master-tls-2c" {
  target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30001.arn}"
  target_id        = "${var.master-2c}"
  port             = 30001
}

###############################################################################
