forked from monzo/etcd3-terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nlb.tf
49 lines (44 loc) · 1.29 KB
/
nlb.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
resource "aws_lb" "nlb" {
name = "${var.role}-${var.environment}"
load_balancer_type = "network"
subnets = var.subnet_ids
internal = var.nlb_internal
tags = {
Name = "${var.role}.${data.aws_region.current.name}.i.${var.environment}.${var.dns}"
environment = var.environment
role = var.role
}
}
resource "aws_lb_listener" "https" {
load_balancer_arn = aws_lb.nlb.id
port = 2379
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.https.arn
type = "forward"
}
}
resource "aws_lb_target_group" "https" {
name = "${var.role}-${var.environment}-https"
port = 2379
protocol = "TCP"
vpc_id = data.aws_vpc.target.id
health_check {
healthy_threshold = 3
unhealthy_threshold = 3
port = 8080
path = "/health"
protocol = "HTTP"
interval = 10
}
}
resource "aws_route53_record" "nlb" {
zone_id = aws_route53_zone.default.id
name = "${var.role}.${data.aws_region.current.name}.i.${var.environment}.${var.dns}"
type = "A"
alias {
name = aws_lb.nlb.dns_name
zone_id = aws_lb.nlb.zone_id
evaluate_target_health = false
}
}