Skip to content

Commit 469ed73

Browse files
authored
fix: Conditionally assign zone attributes only if multizone detected for storage_type_backend="netapp" (#327)
* fix: Conditionally assign zone attributes only if multizone detected for storage_type_backend="netapp"
1 parent c2be8cf commit 469ed73

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ module "google_netapp" {
321321
protocols = var.netapp_protocols
322322
volume_path = "${var.prefix}-${var.netapp_volume_path}"
323323
allowed_clients = join(",", [local.gke_subnet_cidr, local.misc_subnet_cidr])
324+
default_nodepool_locations = var.default_nodepool_locations
324325
depends_on = [ module.gke ]
325326

326327
community_netapp_networking_components_enabled = var.community_netapp_networking_components_enabled

modules/google_netapp/locals.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
locals {
2+
# Determine if deployment is multi-zone (either regional or multiple zones)
3+
is_multizone = length(split(",", var.default_nodepool_locations)) > 1
4+
5+
# Derive primary/replica zones only when multizone is enabled
6+
primary_zone = local.is_multizone ? split(",", var.default_nodepool_locations)[0] : null
7+
replica_zone = local.is_multizone && length(split(",", var.default_nodepool_locations)) > 1 ? split(",", var.default_nodepool_locations)[1] : null
8+
}

modules/google_netapp/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ resource "google_netapp_storage_pool" "netapp-tf-pool" {
4646
capacity_gib = var.capacity_gib
4747
network = var.network
4848

49+
# Conditionally assign zone attributes only if multizone detected
50+
zone = local.is_multizone && local.primary_zone != null ? local.primary_zone : null
51+
replica_zone = local.is_multizone && local.replica_zone != null ? local.replica_zone : null
52+
4953
lifecycle {
5054
ignore_changes = [network]
5155
}

modules/google_netapp/variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ variable "netapp_subnet_cidr" {
5353
default = "192.168.5.0/24"
5454
}
5555

56+
variable "default_nodepool_locations" {
57+
description = "Comma-separated list of default node pool locations"
58+
type = string
59+
}
60+
5661
# Community Contribution
5762
variable "community_netapp_networking_components_enabled" {
5863
description = "Community Contribution. Enable/Disable the deployment of Networking components for Netapp resources. Enabled by default."
5964
type = bool
6065
default = true
61-
}
66+
}

0 commit comments

Comments
 (0)