Skip to content

Commit c4fd0e4

Browse files
committed
Fixed region extracting logic for existing cluster
1 parent 3cf9500 commit c4fd0e4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

oci_lens_terraform/main.tf

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
# oci_lens_terraform/main.tf — Root wrapper (ORM)
33
#############################################
44

5-
# --- Determine the actual region to use ---
5+
# --- Determine the actual cluster ID to use ---
66
locals {
7-
# If using existing cluster, extract region from cluster OCID
8-
cluster_region = var.create_new_cluster ? var.region : split(".", var.cluster_ocid)[3]
97
cluster_id = var.create_new_cluster ? module.cluster[0].oke_cluster_id : var.cluster_ocid
108
}
119

12-
# --- User-selected or auto-detected region provider (default) ---
10+
# --- User-selected region provider (default) ---
1311
provider "oci" {
14-
region = local.cluster_region
12+
region = var.region
1513
}
1614

1715
# --- Discover true home region & configure alias ---
@@ -36,7 +34,7 @@ provider "oci" {
3634

3735
provider "oci" {
3836
alias = "current_region"
39-
region = local.cluster_region
37+
region = var.region
4038
}
4139

4240
# --- Create OKE + networking (only when create_new_cluster is true) ---
@@ -80,7 +78,7 @@ provider "kubernetes" {
8078
cluster_ca_certificate = base64decode(local.kube_ca_b64)
8179
exec {
8280
api_version = "client.authentication.k8s.io/v1beta1"
83-
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
81+
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", var.region]
8482
command = "oci"
8583
}
8684
}
@@ -91,7 +89,7 @@ provider "helm" {
9189
cluster_ca_certificate = base64decode(local.kube_ca_b64)
9290
exec {
9391
api_version = "client.authentication.k8s.io/v1beta1"
94-
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
92+
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", var.region]
9593
command = "oci"
9694
}
9795
}
@@ -124,7 +122,7 @@ module "app" {
124122

125123
namespace = var.namespace
126124
compartment_ocid = var.compartment_ocid
127-
region = local.cluster_region
125+
region = var.region
128126
cluster_ocid = local.cluster_id
129127
tenancy_ocid = var.tenancy_ocid
130128
create_iam_policy = var.create_iam_policy

0 commit comments

Comments
 (0)