From e00590bd53edab6b0aafd064678b7244b84421f9 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Tue, 20 Feb 2024 14:24:02 +0100 Subject: [PATCH 1/3] Add support for types --- modules/data-catalog-tag/README.md | 36 ++++++++++++++++++++++----- modules/data-catalog-tag/main.tf | 9 +++++-- modules/data-catalog-tag/variables.tf | 7 +++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/modules/data-catalog-tag/README.md b/modules/data-catalog-tag/README.md index 074abfb9d4..226829ed02 100644 --- a/modules/data-catalog-tag/README.md +++ b/modules/data-catalog-tag/README.md @@ -5,6 +5,8 @@ This module allows managing [Data Catalog Tag](https://cloud.google.com/data-cat ## TODO - Add support for entries different than Bigquery resources. +- Ass support to BOOL when [issue](https://github.com/hashicorp/terraform-provider-google/issues/16856) is fixed. +- Add support to RICHTEXT when [issue](https://github.com/hashicorp/terraform-provider-google/issues/13597) is fixed. ## Examples @@ -20,7 +22,18 @@ module "data-catalog-tag" { location = "europe-west1" template = "projects/project-datagov/locations/europe-west1/tagTemplates/demo" fields = { - source = "DB-1" + source = { + string_value = "DB-1" + } + datetime = { + timestamp_value = "2024-02-03T06:50:50.91Z" + } + num = { + double_value = 4.3 + } + pii = { + enum_value = "NONE" + } } } } @@ -40,7 +53,9 @@ module "data-catalog-tag" { location = "europe-west1" template = "projects/project-datagov/locations/europe-west1/tagTemplates/demo" fields = { - source = "DB-1 Table-A" + source = { + string_value = "DB-1 Table-A" + } } } } @@ -61,7 +76,9 @@ module "data-catalog-tag" { location = "europe-west1" template = "projects/project-datagov/locations/europe-west1/tagTemplates/demo" fields = { - source = "DB-1 Table-A Column-B" + source = { + string_value = "DB-1 Table-A Column-B" + } } } } @@ -90,7 +107,9 @@ module "data-catalog-tag" { location = "europe-west1" template = "projects/project-datagov/locations/europe-west1/tagTemplates/demo" fields = { - source = "DB-1 Table-A Column-B" + source = { + string_value = "DB-1 Table-A Column-B" + } } } } @@ -109,7 +128,12 @@ parent: projects/project-data-product/datasets/exposure location: europe-west1 template: projects/project-datagov/locations/europe-west1/tagTemplates/test fields: - owner_email: example@example.com + owner_email: + string_value: example@example.com + num: + double_value: 5 + pii: + enum_value: NONE ``` ## Variables @@ -117,7 +141,7 @@ fields: | name | description | type | required | default | |---|---|:---:|:---:|:---:| | [factories_config](variables.tf#L17) | Paths to data files and folders that enable factory functionality. | object({…}) | | {} | -| [tags](variables.tf#L26) | Tags definitions in the form {TAG => TAG_DEFINITION}. | map(object({…})) | | {} | +| [tags](variables.tf#L26) | Tags definitions in the form {TAG => TAG_DEFINITION}. | map(object({…})) | | {} | ## Outputs diff --git a/modules/data-catalog-tag/main.tf b/modules/data-catalog-tag/main.tf index 1a08de288e..0b2f85326c 100644 --- a/modules/data-catalog-tag/main.tf +++ b/modules/data-catalog-tag/main.tf @@ -31,8 +31,13 @@ resource "google_data_catalog_tag" "engine" { dynamic "fields" { for_each = each.value.fields content { - field_name = fields.key - string_value = fields.value + field_name = fields.key + display_name = try(fields.value.display_name, null) + order = try(fields.value.order, null) + string_value = try(fields.value.string_value, null) + double_value = try(fields.value.double_value, null) + enum_value = try(fields.value.enum_value, null) + timestamp_value = try(fields.value.timestamp_value, null) } } } diff --git a/modules/data-catalog-tag/variables.tf b/modules/data-catalog-tag/variables.tf index 6bcc3777c5..7456ca90ff 100644 --- a/modules/data-catalog-tag/variables.tf +++ b/modules/data-catalog-tag/variables.tf @@ -31,7 +31,12 @@ variable "tags" { column = optional(string) location = string template = string - fields = map(string) + fields = map(object({ + double_value = optional(number) + string_value = optional(string) + timestamp_value = optional(string) + enum_value = optional(string) + })) })) default = {} } From dcfa4f499ad12126c19473a62ae8981f21d83256 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Tue, 20 Feb 2024 21:43:03 +0100 Subject: [PATCH 2/3] implement feedback --- modules/data-catalog-tag/README.md | 2 +- modules/data-catalog-tag/main.tf | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/data-catalog-tag/README.md b/modules/data-catalog-tag/README.md index 226829ed02..fa2f3379e4 100644 --- a/modules/data-catalog-tag/README.md +++ b/modules/data-catalog-tag/README.md @@ -5,7 +5,7 @@ This module allows managing [Data Catalog Tag](https://cloud.google.com/data-cat ## TODO - Add support for entries different than Bigquery resources. -- Ass support to BOOL when [issue](https://github.com/hashicorp/terraform-provider-google/issues/16856) is fixed. +- Add support to BOOL when [issue](https://github.com/hashicorp/terraform-provider-google/issues/16856) is fixed. - Add support to RICHTEXT when [issue](https://github.com/hashicorp/terraform-provider-google/issues/13597) is fixed. ## Examples diff --git a/modules/data-catalog-tag/main.tf b/modules/data-catalog-tag/main.tf index 0b2f85326c..34a9fada3d 100644 --- a/modules/data-catalog-tag/main.tf +++ b/modules/data-catalog-tag/main.tf @@ -33,10 +33,9 @@ resource "google_data_catalog_tag" "engine" { content { field_name = fields.key display_name = try(fields.value.display_name, null) - order = try(fields.value.order, null) - string_value = try(fields.value.string_value, null) double_value = try(fields.value.double_value, null) enum_value = try(fields.value.enum_value, null) + string_value = try(fields.value.string_value, null) timestamp_value = try(fields.value.timestamp_value, null) } } From e6d7401f49c8cde92d1940a502f94760279f7552 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Thu, 22 Feb 2024 11:27:41 +0100 Subject: [PATCH 3/3] Remove display name field. --- modules/data-catalog-tag/main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/data-catalog-tag/main.tf b/modules/data-catalog-tag/main.tf index 34a9fada3d..ee9d1b7cbb 100644 --- a/modules/data-catalog-tag/main.tf +++ b/modules/data-catalog-tag/main.tf @@ -32,7 +32,6 @@ resource "google_data_catalog_tag" "engine" { for_each = each.value.fields content { field_name = fields.key - display_name = try(fields.value.display_name, null) double_value = try(fields.value.double_value, null) enum_value = try(fields.value.enum_value, null) string_value = try(fields.value.string_value, null)