-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalb.tf
70 lines (63 loc) · 1.83 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
60
61
62
63
64
65
66
67
68
69
70
#########################################
## This file contains a single ALB, #
## two target groups, and two listeners #
## #
## Only 2 of the services need ingress #
#########################################
resource "aws_alb" "demo-alb" {
name = "demo-alb"
subnets = ["${aws_subnet.public.*.id}"]
security_groups = ["${aws_security_group.alb-sg.id}"]
}
resource "aws_alb_target_group" "demo-alb-tg" {
name = "demo-alb-tg"
port = 4200
protocol = "HTTP"
vpc_id = "${aws_vpc.demo-vpc.id}"
target_type = "ip"
health_check {
healthy_threshold = "3"
interval = "30"
matcher = "200,304"
path = "/"
port = "4200"
protocol = "HTTP"
timeout = "5"
unhealthy_threshold = "3"
}
}
resource "aws_alb_target_group" "demo-game-tg" {
name = "demo-game-tg"
port = 8080
protocol = "HTTP"
vpc_id = "${aws_vpc.demo-vpc.id}"
target_type = "ip"
health_check {
healthy_threshold = "3"
interval = "30"
matcher = "200,304"
path = "/"
port = "8080"
protocol = "HTTP"
timeout = "5"
unhealthy_threshold = "3"
}
}
resource "aws_alb_listener" "http" {
load_balancer_arn = "${aws_alb.demo-alb.id}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.demo-alb-tg.id}"
type = "forward"
}
}
resource "aws_alb_listener" "game" {
load_balancer_arn = "${aws_alb.demo-alb.id}"
port = "8080"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.demo-game-tg.id}"
type = "forward"
}
}