Skip to content

Commit 9561e1a

Browse files
authored
fix: add preferred_loadbalancer validation (#627)
fix: add preffered_loadblancer validation
1 parent 2bca25a commit 9561e1a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/oke/cluster.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ resource "oci_containerengine_cluster" "k8s_cluster" {
7171
defined_tags = lookup(var.defined_tags,"service_lb",{})
7272
}
7373

74-
service_lb_subnet_ids = var.preferred_load_balancer == "public" ? [var.cluster_subnets["pub_lb"]] : [var.cluster_subnets["int_lb"]]
74+
service_lb_subnet_ids = [var.cluster_subnets[local.lb_subnet]]
7575
}
7676

7777
lifecycle {
7878
ignore_changes = [defined_tags, freeform_tags, cluster_pod_network_options]
79+
80+
precondition {
81+
condition = var.cluster_subnets[local.lb_subnet] != ""
82+
error_message = "Preferred load balancer references unexisting load balancer. Please check variables preferred_load_balancer and load_balancers."
83+
}
7984
}
8085

8186
vcn_id = var.vcn_id

0 commit comments

Comments
 (0)