-
Notifications
You must be signed in to change notification settings - Fork 0
/
alb.tf
52 lines (46 loc) · 1.16 KB
/
alb.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
50
51
52
# Application load balancer
resource "aws_lb" "terraform-alb" {
name = "terraform-alb"
internal = false
load_balancer_type = "application"
enable_http2 = false
security_groups = [aws_security_group.generic_server.id]
subnets = [
"subnet-027f7c79055623b47",
"subnet-0439b2e8286d570a6",
"subnet-0905bf7456c3c7de5"
]
tags = {
Name = "Terraform_ALB_Isti"
Email = "[email protected]"
Comment = "Made with Terraform"
}
}
# Target group for load balancer
resource "aws_lb_target_group" "tf_group" {
name = "terraform-alb-target"
port = 80
protocol = "HTTP"
vpc_id = var.aws_vpc_id
stickiness {
type = "lb_cookie"
enabled = false
}
health_check {
port = 80
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 2
interval = 5
}
}
# HTTP listener for the load balancer
resource "aws_lb_listener" "tf_listener_http" {
load_balancer_arn = "${aws_lb.terraform-alb.arn}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_lb_target_group.tf_group.arn}"
type = "forward"
}
}