-
Notifications
You must be signed in to change notification settings - Fork 0
/
elb.tf
executable file
·42 lines (35 loc) · 1.19 KB
/
elb.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
data "aws_subnet_ids" "all" {
vpc_id = data.aws_vpc.default.id
}
resource "aws_lb" "server_lb" {
name = "server-${module.variables.env}-nlb"
internal = false
load_balancer_type = "network"
subnets = data.aws_subnet_ids.all.ids
enable_deletion_protection = false
tags = {
Environment = "${(module.variables.is_prod) ? "production" : "staging"}"
}
}
resource "aws_lb_target_group" "server_target_group" {
name = "server-${module.variables.env}-target-group"
port = 8000
protocol = "TCP"
vpc_id = data.aws_vpc.default.id
}
resource "aws_lb_target_group_attachment" "server_cluster_attachment" {
target_group_arn = "${aws_lb_target_group.server_target_group.arn}"
target_id = "${aws_instance.server.id}"
port = 8000
}
resource "aws_lb_listener" "server_https" {
load_balancer_arn = "${aws_lb.server_lb.arn}"
port = "443"
protocol = "TLS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = "${var.elb_certificate[module.variables.env]}"
default_action {
type = "forward"
target_group_arn = "${aws_lb_target_group.server_target_group.arn}"
}
}