-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
load_balancer.tf
68 lines (64 loc) · 2.11 KB
/
load_balancer.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
#------------------------------------------------------------------------------
# ELASTIC LOAD BALANCER - CONSUL
#------------------------------------------------------------------------------
## ELB
resource "aws_elb" "consul_elb" {
name = "${var.names_prefix}-consul-elb"
security_groups = [aws_security_group.elb_security_group.id]
subnets = data.aws_subnet.subnets.*.id
internal = true
cross_zone_load_balancing = true
tags = {
Name = "${var.names_prefix}_consul_elb"
}
listener {
instance_port = "8500"
instance_protocol = "tcp"
lb_port = "80"
lb_protocol = "tcp"
}
}
## Add DNS Record
resource "aws_route53_record" "consul_elb_dns" {
depends_on = [aws_elb.consul_elb]
zone_id = data.aws_route53_zone.hosted_zone.zone_id
name = "consul.${var.domain_name}"
type = "A"
alias {
name = aws_elb.consul_elb.dns_name
zone_id = aws_elb.consul_elb.zone_id
evaluate_target_health = true
}
}
#------------------------------------------------------------------------------
# ELASTIC LOAD BALANCER - NOMAD
#------------------------------------------------------------------------------
## ELB
resource "aws_elb" "nomad_elb" {
name = "${var.names_prefix}-nomad-elb"
security_groups = [aws_security_group.elb_security_group.id]
subnets = data.aws_subnet.subnets.*.id
internal = true
cross_zone_load_balancing = true
tags = {
Name = "${var.names_prefix}_nomad_elb"
}
listener {
instance_port = "4646"
instance_protocol = "tcp"
lb_port = "80"
lb_protocol = "tcp"
}
}
## Add DNS Record
resource "aws_route53_record" "nomad_elb_dns" {
depends_on = [aws_elb.nomad_elb]
zone_id = data.aws_route53_zone.hosted_zone.zone_id
name = "nomad.${var.domain_name}"
type = "A"
alias {
name = aws_elb.nomad_elb.dns_name
zone_id = aws_elb.nomad_elb.zone_id
evaluate_target_health = true
}
}