Skip to content

Commit 3f74bb6

Browse files
committed
updating things
1 parent 46a448f commit 3f74bb6

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ module "bigquery" {
3535
project_id = "<PROJECT ID>"
3636
location = "US"
3737
default_table_expiration_ms = 3600000
38-
38+
tag_key = "56789"
39+
tag_value = "production"
40+
3941
tables = [
4042
{
4143
table_id = "foo",
@@ -101,9 +103,6 @@ module "bigquery" {
101103
env = "dev"
102104
billable = "true"
103105
}
104-
resource_tags = {
105-
short_name = "123456789012/environment"
106-
}
107106
}
108107
```
109108

main.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ locals {
2828
}
2929
}
3030

31+
data "google_tags_tag_value" "tag_value" {
32+
count = var.tag_key != "" && var.tag_value != "" ? 1 : 0
33+
parent = "tagKeys/${var.tag_key}"
34+
short_name = var.tag_value
35+
}
36+
3137
resource "google_bigquery_dataset" "main" {
3238
dataset_id = var.dataset_id
3339
friendly_name = var.dataset_name
@@ -38,7 +44,15 @@ resource "google_bigquery_dataset" "main" {
3844
max_time_travel_hours = var.max_time_travel_hours
3945
project = var.project_id
4046
labels = var.dataset_labels
41-
resource_tags = var.resource_tags
47+
48+
dynamic "resource_tags" {
49+
for_each = var.tag_key != "" && var.tag_value != "" ? [1] : []
50+
content {
51+
key = data.google_tags_tag_value.tag_value[0].parent
52+
value = data.google_tags_tag_value.tag_value[0].id
53+
}
54+
}
55+
4256
dynamic "default_encryption_configuration" {
4357
for_each = var.encryption_key == null ? [] : [var.encryption_key]
4458
content {

variables.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,16 @@ variable "dataset_labels" {
7777
type = map(string)
7878
default = {}
7979
}
80-
variable "resource_tags" {
81-
description = "A map of resource tags to add to the dataset"
82-
type = map(string)
83-
default = {}
80+
variable "tag_key" {
81+
description = "The ID of the parent TagKey"
82+
type = string
83+
default = ""
84+
}
85+
86+
variable "tag_value" {
87+
description = "The short name of the TagValue"
88+
type = string
89+
default = ""
8490
}
8591

8692
# Format: list(objects)

0 commit comments

Comments
 (0)