-
Notifications
You must be signed in to change notification settings - Fork 30
/
lb.tf
81 lines (69 loc) · 2.17 KB
/
lb.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
/**
* Copyright (C) 2018-2020 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "aws_lb" "apiary_hms_rw_lb" {
count = var.hms_instance_type == "ecs" ? 1 : 0
name = "${local.instance_alias}-hms-rw-lb"
load_balancer_type = "network"
subnets = var.private_subnets
internal = true
idle_timeout = var.elb_timeout
tags = var.apiary_tags
}
resource "aws_lb_target_group" "apiary_hms_rw_tg" {
count = var.hms_instance_type == "ecs" ? 1 : 0
name = "${local.instance_alias}-hms-rw-tg"
port = 9083
protocol = "TCP"
vpc_id = var.vpc_id
target_type = "ip"
health_check {
protocol = "TCP"
}
tags = var.apiary_tags
depends_on = [aws_lb.apiary_hms_rw_lb]
}
resource "aws_lb_listener" "hms_rw_listener" {
count = var.hms_instance_type == "ecs" ? 1 : 0
load_balancer_arn = aws_lb.apiary_hms_rw_lb[0].arn
port = "9083"
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.apiary_hms_rw_tg[0].arn
type = "forward"
}
}
resource "aws_lb" "apiary_hms_ro_lb" {
count = var.hms_instance_type == "ecs" ? 1 : 0
name = "${local.instance_alias}-hms-ro-lb"
load_balancer_type = "network"
subnets = var.private_subnets
internal = true
idle_timeout = var.elb_timeout
tags = var.apiary_tags
}
resource "aws_lb_target_group" "apiary_hms_ro_tg" {
count = var.hms_instance_type == "ecs" ? 1 : 0
depends_on = [aws_lb.apiary_hms_ro_lb]
name = "${local.instance_alias}-hms-ro-tg"
port = 9083
protocol = "TCP"
vpc_id = var.vpc_id
target_type = "ip"
health_check {
protocol = "TCP"
}
tags = var.apiary_tags
}
resource "aws_lb_listener" "hms_ro_listener" {
count = var.hms_instance_type == "ecs" ? 1 : 0
load_balancer_arn = aws_lb.apiary_hms_ro_lb[0].arn
port = "9083"
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.apiary_hms_ro_tg[0].arn
type = "forward"
}
}