-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadbalancer.tf
40 lines (34 loc) · 935 Bytes
/
loadbalancer.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
resource "aws_lb_target_group" "django-server" {
name = "django-server"
port = 8000
protocol = "TCP"
vpc_id = aws_vpc.todo-vpc.id
health_check {
protocol = "HTTP"
path = "/"
port = 8000
}
}
resource "aws_lb" "network" {
name = "my-network-lb"
internal = true
load_balancer_type = "network"
subnets = [aws_subnet.private-subnet.id]
}
resource "aws_lb_listener" "frontend" {
load_balancer_arn = aws_lb.network.arn
port = 8000
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.django-server.arn
}
}
resource "aws_lb_target_group_attachment" "attachment" {
target_group_arn = aws_lb_target_group.django-server.arn
target_id = aws_instance.private_instance.id
port = 8000
}
output "aws_lb_DNS" {
value = aws_lb.network.dns_name
}