-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinternal-elb.tf
60 lines (50 loc) · 1.44 KB
/
internal-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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module "internal_nodeport_elb" {
count = var.internal_elb.enabled ? 1 : 0
source = "terraform-aws-modules/elb/aws"
version = "~> 2.0"
name = replace("${var.cluster_name}-internal-elb", "_", "-")
subnets = aws_subnet.cluster_private.*.id
security_groups = [aws_security_group.internal_elb_sg[0].id]
internal = true
listener = [
{
instance_port = var.internal_elb.instance_port
instance_protocol = "HTTP"
lb_port = "80"
lb_protocol = "HTTP"
},
{
instance_port = var.internal_elb.instance_ssl_port
instance_protocol = "HTTP"
lb_port = "443"
lb_protocol = "HTTPS"
ssl_certificate_id = var.internal_elb.cert_arn
},
]
health_check = {
target = "HTTP:${var.internal_elb.instance_health_check_port}/"
interval = 30
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 5
}
}
resource "aws_security_group" "internal_elb_sg" {
count = var.internal_elb.enabled ? 1 : 0
name = replace("${var.cluster_name}-internal-elb-sg", "_", "-")
vpc_id = var.vpc_id
ingress {
description = "internal access"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [var.vpc_cidr]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = local.common_tags
}