From 0e908279a60d5655ab3990fcad287fcc89b726b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mitka?= <75326685+lukasz-mitka@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:43:43 +0100 Subject: [PATCH 1/2] Remove condition from data.google_compute_zones.available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Condition causes an issue when `var.zone` is computed in the host Terraform code. ``` │ Error: Invalid count argument │ │ on .terraform/modules/pg/modules/postgresql/read_replica.tf line 26, in data "google_compute_zones" "available": │ 26: count = var.zone == null ? 1 : 0 │ │ The "count" value depends on resource attributes that cannot be determined │ until apply, so Terraform cannot predict how many instances will be │ created. To work around this, use the -target argument to first apply only │ the resources that the count depends on. ``` --- modules/postgresql/read_replica.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/postgresql/read_replica.tf b/modules/postgresql/read_replica.tf index c4fce644..8a9b2dc4 100644 --- a/modules/postgresql/read_replica.tf +++ b/modules/postgresql/read_replica.tf @@ -19,11 +19,10 @@ locals { for x in var.read_replicas : "${var.name}-replica${var.read_replica_name_suffix}${x.name}" => x } // Zone for replica instances - zone = var.zone == null ? data.google_compute_zones.available[0].names[0] : var.zone + zone = var.zone == null ? data.google_compute_zones.available.names[0] : var.zone } data "google_compute_zones" "available" { - count = var.zone == null ? 1 : 0 project = var.project_id region = var.region } From 2fc6e766ab459475063df0ddc08275a0f3879dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mitka?= <75326685+lukasz-mitka@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:00:43 +0100 Subject: [PATCH 2/2] empty