-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathload_balancers.tf
94 lines (86 loc) · 2.64 KB
/
load_balancers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Application Load Balancer
resource "aws_alb" "demo_internal_alb" {
name = "demo-internal-alb"
internal = false
security_groups = ["${aws_security_group.demo_internal_alb_sg.id}"]
subnets = ["${aws_subnet.demo_public_subnet_aza.id}", "${aws_subnet.demo_public_subnet_azb.id}"]
tags {
Name = "demo_internal_alb"
}
}
resource "aws_alb_listener" "internal_alb_listener" {
load_balancer_arn = "${aws_alb.demo_internal_alb.arn}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.internal_target_group.arn}"
type = "forward"
}
}
resource "aws_alb" "demo_frontend_alb" {
name = "demo-front-alb"
subnets = ["${aws_subnet.demo_public_subnet_aza.id}", "${aws_subnet.demo_public_subnet_azb.id}"]
security_groups = ["${aws_security_group.demo_frontend_alb_sg.id}"]
internal = "false"
tags {
Name = "demo_frontend_alb"
}
}
resource "aws_alb_listener" "frontend_alb_listener" {
load_balancer_arn = "${aws_alb.demo_frontend_alb.arn}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.frontend_target_group.arn}"
type = "forward"
}
}
resource "aws_alb_listener_rule" "frontend_listener_rule" {
depends_on = ["aws_alb_target_group.frontend_target_group"]
listener_arn = "${aws_alb_listener.frontend_alb_listener.arn}"
priority = "1"
action {
type = "forward"
target_group_arn = "${aws_alb_target_group.frontend_target_group.id}"
}
condition {
field = "path-pattern"
values = ["/"]
}
}
#resource "aws_alb_listener" "alb-https" {
# load_balancer_arn = "${aws_alb.demo_internal_alb.arn}"
# port = "443"
# protocol = "HTTPS"
# ssl_policy = "ELBSecurityPolicy-2015-05"
# certificate_arn = "${var.web_ssl_certificate_id}"
# default_action {
# target_group_arn = "${aws_alb_target_group.web.arn}"
# type = "forward"
# }
#}
#resource "aws_alb_listener_rule" "api-https" {
# listener_arn = "${aws_alb_listener.alb-https.arn}"
# priority = 1
# action {
# type = "forward"
# target_group_arn = "${aws_alb_target_group.api.arn}"
# }
# condition {
# field = "path-pattern"
# values = ["/api*"]
# }
#}
#resource "aws_alb_target_group" "web" {
# name = "web-alb-tg"
# port = 8080
# protocol = "HTTP"
# vpc_id = "${aws_vpc.main.id}"
# deregistration_delay = 0
# health_check {
# healthy_threshold = 2
# unhealthy_threshold = 2
# timeout = 3
# path = "/health/"
# }
#}