-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathalb.tf
59 lines (51 loc) · 1.71 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
53
54
55
56
57
58
59
################################################################################
# Supporting Resources
################################################################################
module "alb_http_sg" {
source = "terraform-aws-modules/security-group/aws//modules/http-80"
version = "~> 4.0"
name = var.alb_sg_name
vpc_id = module.vpc.vpc_id
description = var.alb_sg_description
ingress_cidr_blocks = var.alb_sg_ingress_cidr_blocks
tags = var.alb_sg_tags
}
################################################################################
# Application load balancer (ALB)
################################################################################
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 6.0"
name = var.alb_name
vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
security_groups = [module.alb_http_sg.security_group_id]
http_tcp_listeners = [
{
port = 80
protocol = "HTTP"
target_group_index = 0
}
]
target_groups = [
{
name = var.alb_target_group_name
backend_protocol = "HTTP"
backend_port = 80
target_type = "instance"
stickiness = { "enabled" = true, "type" = "lb_cookie" }
health_check = {
enabled = true
interval = 30
path = "/phpinfo.php"
port = "traffic-port"
healthy_threshold = 3
unhealthy_threshold = 3
timeout = 6
protocol = "HTTP"
matcher = "200-399"
}
},
]
tags = var.alb_tags
}