Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Data Catalog Tag - Add support for types #2100

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions modules/data-catalog-tag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
wiktorn marked this conversation as resolved.
Show resolved Hide resolved
- Add support to RICHTEXT when [issue](https://github.com/hashicorp/terraform-provider-google/issues/13597) is fixed.

## Examples

Expand All @@ -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 = {
wiktorn marked this conversation as resolved.
Show resolved Hide resolved
string_value = "DB-1"
}
datetime = {
timestamp_value = "2024-02-03T06:50:50.91Z"
}
num = {
double_value = 4.3
}
pii = {
enum_value = "NONE"
}
}
}
}
Expand All @@ -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"
}
}
}
}
Expand All @@ -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"
}
}
}
}
Expand Down Expand Up @@ -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"
}
}
}
}
Expand All @@ -109,15 +128,20 @@ parent: projects/project-data-product/datasets/exposure
location: europe-west1
template: projects/project-datagov/locations/europe-west1/tagTemplates/test
fields:
owner_email: [email protected]
owner_email:
wiktorn marked this conversation as resolved.
Show resolved Hide resolved
string_value: [email protected]
num:
double_value: 5
pii:
enum_value: NONE
```
<!-- BEGIN TFDOC -->
## Variables

| 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

Expand Down
9 changes: 7 additions & 2 deletions modules/data-catalog-tag/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
lcaggio marked this conversation as resolved.
Show resolved Hide resolved
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)
lcaggio marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
7 changes: 6 additions & 1 deletion modules/data-catalog-tag/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ variable "tags" {
column = optional(string)
location = string
template = string
fields = map(string)
fields = map(object({
double_value = optional(number)
wiktorn marked this conversation as resolved.
Show resolved Hide resolved
string_value = optional(string)
timestamp_value = optional(string)
enum_value = optional(string)
wiktorn marked this conversation as resolved.
Show resolved Hide resolved
}))
}))
default = {}
}
Loading