forked from terraform-iaac/terraform-kubernetes-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
25 lines (25 loc) · 812 Bytes
/
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
resource "kubernetes_service" "service" {
metadata {
name = var.app_name
namespace = var.app_namespace
annotations = var.annotations
labels = local.labels
}
spec {
selector = local.labels
type = var.type
load_balancer_ip = var.type == "LoadBalancer" ? var.load_balancer_ip : null
load_balancer_source_ranges = var.type == "LoadBalancer" ? var.load_balancer_ips_whitelist : null
dynamic "port" {
iterator = port
for_each = var.port_mapping
content {
name = port.value.name
port = port.value.external_port
protocol = port.value.protocol
node_port = port.value.node_port
target_port = port.value.internal_port
}
}
}
}