-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheks-alb.tf
50 lines (43 loc) · 1.32 KB
/
eks-alb.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
module "lb" {
source = "terraform-aws-modules/alb/aws"
version = "5.10.0"
create_lb = var.loadbalancer_enabled
name = var.cluster_name
load_balancer_type = "network"
vpc_id = var.vpc_id
subnets = var.loadbalancer_subnets
enable_cross_zone_load_balancing = true
http_tcp_listeners = [
for listener in local.loadbalancer_listeners :
{
port = listener.port
protocol = "TCP"
target_group_index = index(local.loadbalancer_listeners, listener)
}
]
target_groups = [
for listener in local.loadbalancer_listeners :
{
backend_port = listener.nodePort
backend_protocol = "TCP"
target_type = "instance"
}
]
tags = var.tags
}
resource "aws_security_group" "worker_http_ingress" {
count = var.loadbalancer_enabled ? 1 : 0
name_prefix = "${var.cluster_name}-ingress"
description = "Allows access from anywhere to the ingress NodePorts"
vpc_id = var.vpc_id
dynamic "ingress" {
for_each = local.loadbalancer_listeners
content {
to_port = ingress.value.nodePort
from_port = ingress.value.nodePort
cidr_blocks = ingress.value.cidr
protocol = "tcp"
description = ingress.value.name
}
}
}