Module Data Catalog Tag - Add support for types (#2100)

* Add support for types

* implement feedback

* Remove display name field.
This commit is contained in:
lcaggio 2024-02-22 11:51:54 +01:00 committed by GitHub
parent 220ab76e40
commit 1c26c8f8a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 9 deletions

View File

@ -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.
- 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
@ -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
```
<!-- BEGIN TFDOC -->
## 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. | <code title="object&#40;&#123;&#10; tags &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [tags](variables.tf#L26) | Tags definitions in the form {TAG => TAG_DEFINITION}. | <code title="map&#40;object&#40;&#123;&#10; project_id &#61; string&#10; parent &#61; string&#10; column &#61; optional&#40;string&#41;&#10; location &#61; string&#10; template &#61; string&#10; fields &#61; map&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [tags](variables.tf#L26) | Tags definitions in the form {TAG => TAG_DEFINITION}. | <code title="map&#40;object&#40;&#123;&#10; project_id &#61; string&#10; parent &#61; string&#10; column &#61; optional&#40;string&#41;&#10; location &#61; string&#10; template &#61; string&#10; fields &#61; map&#40;object&#40;&#123;&#10; double_value &#61; optional&#40;number&#41;&#10; string_value &#61; optional&#40;string&#41;&#10; timestamp_value &#61; optional&#40;string&#41;&#10; enum_value &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
## Outputs

View File

@ -31,8 +31,11 @@ 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
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)
}
}
}

View File

@ -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 = {}
}