-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
107 lines (83 loc) · 2.18 KB
/
main.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
95
96
97
98
99
100
101
102
103
104
105
106
107
provider "aws" {
region = "us-east-1"
}
data "aws_vpc" "default" {
default = true
}
data "aws_subnet" "default" {
for_each = toset(["use1-az1", "use1-az2"])
availability_zone_id = each.key
default_for_az = true
}
###################################################
# Network Load Balancer
###################################################
module "nlb" {
source = "../../modules/nlb"
# source = "tedilabs/load-balancer/aws//modules/nlb"
# version = "~> 1.0.0"
name = "tedilabs-nlb-instance"
is_public = false
ip_address_type = "IPV4"
network_mapping = {
for az, subnet in data.aws_subnet.default :
az => {
subnet = subnet.id
}
}
## Attributes
cross_zone_load_balancing_enabled = true
deletion_protection_enabled = false
listeners = [{
port = 80
protocol = "TCP"
target_group = module.target_group.arn
}]
## Access Log
access_log = {
enabled = false
s3_bucket = {
name = "my-bucket"
key_prefix = "/tedilabs-nlb-instance/"
}
}
tags = {
"project" = "terraform-aws-load-balancer-examples"
}
}
###################################################
# Instance Target Group for Network Load Balancer
###################################################
module "target_group" {
source = "../../modules/nlb-instance-target-group"
# source = "tedilabs/load-balancer/aws//modules/nlb-instance-target-group"
# version = "~> 1.0.0"
name = "tedilabs-nlb-instance-tg"
vpc_id = data.aws_vpc.default.id
port = 80
protocol = "TCP"
## Attributes
terminate_connection_on_deregistration = false
deregistration_delay = 300
preserve_client_ip = true
proxy_protocol_v2 = false
stickiness_enabled = true
targets = [
# {
# instance = "i-xxxx"
# },
]
health_check = {
protocol = "HTTP"
port = 80
port_override = true
path = "/health"
interval = 10
timeout = 5
healthy_threshold = 3
unhealthy_threshold = 3
}
tags = {
"project" = "terraform-aws-load-balancer-examples"
}
}