-
Notifications
You must be signed in to change notification settings - Fork 0
/
lb.tf
43 lines (38 loc) · 1.02 KB
/
lb.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
resource "aws_lb" "suricata" {
name = "suricata-load-balancer"
internal = true
load_balancer_type = "network"
subnets = [var.subnet_id]
tags = var.tags
}
resource "aws_lb_target_group" "suricata" {
name = "suricata-target-group"
port = var.vxlan_port
protocol = "UDP"
target_type = "instance"
vpc_id = data.aws_vpc.target.id
health_check {
port = 80
protocol = "TCP"
}
}
resource "aws_lb_target_group_attachment" "suricata" {
target_group_arn = aws_lb_target_group.suricata.arn
target_id = aws_instance.suricata.id
}
resource "aws_lb_listener" "suricata" {
load_balancer_arn = aws_lb.suricata.id
port = 4789
protocol = "UDP"
tags = var.tags
default_action {
target_group_arn = aws_lb_target_group.suricata.id
type = "forward"
}
}
data "aws_subnet" "selected" {
id = var.subnet_id
}
data "aws_vpc" "target" {
id = data.aws_subnet.selected.vpc_id
}