From 11457fbd8e069bf05c58b2f132ffde3390c32c8c Mon Sep 17 00:00:00 2001 From: Francesco Spinelli Date: Wed, 8 Nov 2023 18:27:23 +0100 Subject: [PATCH 1/3] bug fix --- modules/dataproc/README.md | 2 +- modules/dataproc/main.tf | 10 +++++----- modules/dataproc/variables.tf | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/dataproc/README.md b/modules/dataproc/README.md index 5cd220cbaa..f00101345c 100644 --- a/modules/dataproc/README.md +++ b/modules/dataproc/README.md @@ -149,7 +149,7 @@ module "processing-dp-cluster" { | [name](variables.tf#L235) | Cluster name. | string | ✓ | | | [project_id](variables.tf#L250) | Project ID. | string | ✓ | | | [region](variables.tf#L255) | Dataproc region. | string | ✓ | | -| [dataproc_config](variables.tf#L17) | Dataproc cluster config. | object({…}) | | {} | +| [dataproc_config](variables.tf#L17) | Dataproc cluster config. | object({…}) | | {} | | [group_iam](variables.tf#L185) | Authoritative IAM binding for organization groups, in {GROUP_EMAIL => [ROLES]} format. Group emails need to be static. Can be used in combination with the `iam` variable. | map(list(string)) | | {} | | [iam](variables.tf#L192) | IAM bindings in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} | | [iam_bindings](variables.tf#L199) | Authoritative IAM bindings in {KEY => {role = ROLE, members = [], condition = {}}}. Keys are arbitrary. | map(object({…})) | | {} | diff --git a/modules/dataproc/main.tf b/modules/dataproc/main.tf index 55bef5c70e..53f7321073 100644 --- a/modules/dataproc/main.tf +++ b/modules/dataproc/main.tf @@ -108,8 +108,8 @@ resource "google_dataproc_cluster" "cluster" { dynamic "accelerators" { for_each = var.dataproc_config.cluster_config.worker_config.accelerators == null ? [] : [""] content { - accelerator_type = var.dataproc_config.cluster_config.accelerators.accelerator_type - accelerator_count = var.dataproc_config.cluster_config.accelerators.accelerator_count + accelerator_type = var.dataproc_config.cluster_config.worker_config.accelerators.accelerator_type + accelerator_count = var.dataproc_config.cluster_config.worker_config.accelerators.accelerator_count } } } @@ -185,10 +185,10 @@ resource "google_dataproc_cluster" "cluster" { for_each = var.dataproc_config.cluster_config.dataproc_metric_config == null ? [] : [""] content { dynamic "metrics" { - for_each = var.dataproc_config.cluster_config.dataproc_metric_config.metrics == null ? [] : [""] + for_each = var.dataproc_config.cluster_config.dataproc_metric_config.metrics == null ? [] : var.dataproc_config.cluster_config.dataproc_metric_config.metrics content { - metric_source = var.dataproc_config.cluster_config.dataproc_metric_config.metrics.metric_source - metric_overrides = var.dataproc_config.cluster_config.dataproc_metric_config.metrics.metric_overrides + metric_source = metrics.value.metric_source + metric_overrides = metrics.value.metric_overrides } } } diff --git a/modules/dataproc/variables.tf b/modules/dataproc/variables.tf index 8b77c5b96b..f4170a94f0 100644 --- a/modules/dataproc/variables.tf +++ b/modules/dataproc/variables.tf @@ -128,7 +128,7 @@ variable "dataproc_config" { dataproc_metric_config = optional(object({ metrics = list(object({ metric_source = string - metric_overrides = optional(string) + metric_overrides = optional(list(string)) })) })) metastore_config = optional(object({ From ddbcc3f16cda1ab1adcbaf0a0049e7b246fa4b94 Mon Sep 17 00:00:00 2001 From: Francesco Spinelli Date: Wed, 8 Nov 2023 18:27:23 +0100 Subject: [PATCH 2/3] bug fix --- modules/dataproc/README.md | 2 +- modules/dataproc/main.tf | 10 +++++----- modules/dataproc/variables.tf | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/dataproc/README.md b/modules/dataproc/README.md index 5cd220cbaa..f00101345c 100644 --- a/modules/dataproc/README.md +++ b/modules/dataproc/README.md @@ -149,7 +149,7 @@ module "processing-dp-cluster" { | [name](variables.tf#L235) | Cluster name. | string | ✓ | | | [project_id](variables.tf#L250) | Project ID. | string | ✓ | | | [region](variables.tf#L255) | Dataproc region. | string | ✓ | | -| [dataproc_config](variables.tf#L17) | Dataproc cluster config. | object({…}) | | {} | +| [dataproc_config](variables.tf#L17) | Dataproc cluster config. | object({…}) | | {} | | [group_iam](variables.tf#L185) | Authoritative IAM binding for organization groups, in {GROUP_EMAIL => [ROLES]} format. Group emails need to be static. Can be used in combination with the `iam` variable. | map(list(string)) | | {} | | [iam](variables.tf#L192) | IAM bindings in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} | | [iam_bindings](variables.tf#L199) | Authoritative IAM bindings in {KEY => {role = ROLE, members = [], condition = {}}}. Keys are arbitrary. | map(object({…})) | | {} | diff --git a/modules/dataproc/main.tf b/modules/dataproc/main.tf index 55bef5c70e..53f7321073 100644 --- a/modules/dataproc/main.tf +++ b/modules/dataproc/main.tf @@ -108,8 +108,8 @@ resource "google_dataproc_cluster" "cluster" { dynamic "accelerators" { for_each = var.dataproc_config.cluster_config.worker_config.accelerators == null ? [] : [""] content { - accelerator_type = var.dataproc_config.cluster_config.accelerators.accelerator_type - accelerator_count = var.dataproc_config.cluster_config.accelerators.accelerator_count + accelerator_type = var.dataproc_config.cluster_config.worker_config.accelerators.accelerator_type + accelerator_count = var.dataproc_config.cluster_config.worker_config.accelerators.accelerator_count } } } @@ -185,10 +185,10 @@ resource "google_dataproc_cluster" "cluster" { for_each = var.dataproc_config.cluster_config.dataproc_metric_config == null ? [] : [""] content { dynamic "metrics" { - for_each = var.dataproc_config.cluster_config.dataproc_metric_config.metrics == null ? [] : [""] + for_each = var.dataproc_config.cluster_config.dataproc_metric_config.metrics == null ? [] : var.dataproc_config.cluster_config.dataproc_metric_config.metrics content { - metric_source = var.dataproc_config.cluster_config.dataproc_metric_config.metrics.metric_source - metric_overrides = var.dataproc_config.cluster_config.dataproc_metric_config.metrics.metric_overrides + metric_source = metrics.value.metric_source + metric_overrides = metrics.value.metric_overrides } } } diff --git a/modules/dataproc/variables.tf b/modules/dataproc/variables.tf index 8b77c5b96b..f4170a94f0 100644 --- a/modules/dataproc/variables.tf +++ b/modules/dataproc/variables.tf @@ -128,7 +128,7 @@ variable "dataproc_config" { dataproc_metric_config = optional(object({ metrics = list(object({ metric_source = string - metric_overrides = optional(string) + metric_overrides = optional(list(string)) })) })) metastore_config = optional(object({ From b1a80a158db7f42cd3c79314e157d3708e866b01 Mon Sep 17 00:00:00 2001 From: Francesco Spinelli Date: Thu, 9 Nov 2023 14:41:33 +0100 Subject: [PATCH 3/3] fix dinamic for_each --- modules/dataproc/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dataproc/main.tf b/modules/dataproc/main.tf index 53f7321073..f229d7c7ae 100644 --- a/modules/dataproc/main.tf +++ b/modules/dataproc/main.tf @@ -185,7 +185,7 @@ resource "google_dataproc_cluster" "cluster" { for_each = var.dataproc_config.cluster_config.dataproc_metric_config == null ? [] : [""] content { dynamic "metrics" { - for_each = var.dataproc_config.cluster_config.dataproc_metric_config.metrics == null ? [] : var.dataproc_config.cluster_config.dataproc_metric_config.metrics + for_each = coalesce(var.dataproc_config.cluster_config.dataproc_metric_config.metrics, []) content { metric_source = metrics.value.metric_source metric_overrides = metrics.value.metric_overrides