2017-11-07 21:56:50 -08:00
|
|
|
# Network Load Balancer for Ingress
|
|
|
|
resource "aws_lb" "ingress" {
|
2018-03-03 17:52:01 -08:00
|
|
|
name = "${var.name}-ingress"
|
2017-11-07 21:56:50 -08:00
|
|
|
load_balancer_type = "network"
|
|
|
|
internal = false
|
|
|
|
|
2018-02-26 22:16:34 -08:00
|
|
|
subnets = ["${var.subnet_ids}"]
|
2018-03-10 22:50:29 -08:00
|
|
|
|
|
|
|
enable_cross_zone_load_balancing = true
|
2017-11-07 21:56:50 -08:00
|
|
|
}
|
|
|
|
|
2018-02-16 13:18:27 +00:00
|
|
|
# Forward HTTP traffic to workers
|
2017-11-07 21:56:50 -08:00
|
|
|
resource "aws_lb_listener" "ingress-http" {
|
|
|
|
load_balancer_arn = "${aws_lb.ingress.arn}"
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 80
|
|
|
|
|
|
|
|
default_action {
|
|
|
|
type = "forward"
|
|
|
|
target_group_arn = "${aws_lb_target_group.workers-http.arn}"
|
2017-09-17 21:40:33 -07:00
|
|
|
}
|
2017-11-07 21:56:50 -08:00
|
|
|
}
|
2017-09-17 21:40:33 -07:00
|
|
|
|
2018-02-16 13:18:27 +00:00
|
|
|
# Forward HTTPS traffic to workers
|
2017-11-07 21:56:50 -08:00
|
|
|
resource "aws_lb_listener" "ingress-https" {
|
|
|
|
load_balancer_arn = "${aws_lb.ingress.arn}"
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 443
|
|
|
|
|
|
|
|
default_action {
|
|
|
|
type = "forward"
|
|
|
|
target_group_arn = "${aws_lb_target_group.workers-https.arn}"
|
2017-09-17 21:40:33 -07:00
|
|
|
}
|
2017-11-07 21:56:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Network Load Balancer target groups of instances
|
|
|
|
|
|
|
|
resource "aws_lb_target_group" "workers-http" {
|
2018-03-03 17:52:01 -08:00
|
|
|
name = "${var.name}-workers-http"
|
2018-02-26 22:16:34 -08:00
|
|
|
vpc_id = "${var.vpc_id}"
|
2017-11-07 21:56:50 -08:00
|
|
|
target_type = "instance"
|
|
|
|
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 80
|
2017-09-17 21:40:33 -07:00
|
|
|
|
2017-09-28 00:46:17 -07:00
|
|
|
# Ingress Controller HTTP health check
|
2017-09-17 21:40:33 -07:00
|
|
|
health_check {
|
2017-11-07 21:56:50 -08:00
|
|
|
protocol = "HTTP"
|
|
|
|
port = 10254
|
|
|
|
path = "/healthz"
|
|
|
|
|
|
|
|
# NLBs required to use same healthy and unhealthy thresholds
|
|
|
|
healthy_threshold = 3
|
|
|
|
unhealthy_threshold = 3
|
|
|
|
|
|
|
|
# Interval between health checks required to be 10 or 30
|
|
|
|
interval = 10
|
2017-09-17 21:40:33 -07:00
|
|
|
}
|
2017-11-07 21:56:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_lb_target_group" "workers-https" {
|
2018-03-03 17:52:01 -08:00
|
|
|
name = "${var.name}-workers-https"
|
2018-02-26 22:16:34 -08:00
|
|
|
vpc_id = "${var.vpc_id}"
|
2017-11-07 21:56:50 -08:00
|
|
|
target_type = "instance"
|
|
|
|
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 443
|
2017-09-17 21:40:33 -07:00
|
|
|
|
2017-11-07 21:56:50 -08:00
|
|
|
# Ingress Controller HTTP health check
|
|
|
|
health_check {
|
|
|
|
protocol = "HTTP"
|
|
|
|
port = 10254
|
|
|
|
path = "/healthz"
|
|
|
|
|
|
|
|
# NLBs required to use same healthy and unhealthy thresholds
|
|
|
|
healthy_threshold = 3
|
|
|
|
unhealthy_threshold = 3
|
|
|
|
|
|
|
|
# Interval between health checks required to be 10 or 30
|
|
|
|
interval = 10
|
|
|
|
}
|
2017-09-17 21:40:33 -07:00
|
|
|
}
|