Skip to content

Commit c07d42e

Browse files
lord-skinnerrohilla-anuj
andauthoredOct 16, 2024··
feature(TPG>=5.39)!: add resource_tags (#354)
Co-authored-by: Anuj Rohilla <anuj.rohilla@elastic.co> Co-authored-by: Anuj Rohilla <163002505+rohilla-anuj@users.noreply.github.com>
1 parent a96a593 commit c07d42e

File tree

10 files changed

+169
-138
lines changed

10 files changed

+169
-138
lines changed
 

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module "bigquery" {
3535
project_id = "<PROJECT ID>"
3636
location = "US"
3737
default_table_expiration_ms = 3600000
38+
resource_tags = {"<PROJECT>/<TAG KEY>":"<TAG VALUE>"}
3839
3940
tables = [
4041
{
@@ -199,6 +200,7 @@ This module provisions a dataset and a list of tables with associated JSON schem
199200
| materialized\_views | A list of objects which includes view\_id, view\_query, clustering, time\_partitioning, range\_partitioning, expiration\_time and labels | <pre>list(object({<br> view_id = string,<br> description = optional(string),<br> query = string,<br> enable_refresh = bool,<br> refresh_interval_ms = string,<br> clustering = list(string),<br> time_partitioning = object({<br> expiration_ms = string,<br> field = string,<br> type = string,<br> require_partition_filter = bool,<br> }),<br> range_partitioning = object({<br> field = string,<br> range = object({<br> start = string,<br> end = string,<br> interval = string,<br> }),<br> }),<br> expiration_time = string,<br> max_staleness = optional(string),<br> labels = map(string),<br> }))</pre> | `[]` | no |
200201
| max\_time\_travel\_hours | Defines the time travel window in hours | `number` | `null` | no |
201202
| project\_id | Project where the dataset and table are created | `string` | n/a | yes |
203+
| resource\_tags | A map of resource tags to add to the dataset | `map(string)` | `{}` | no |
202204
| routines | A list of objects which include routine\_id, routine\_type, routine\_language, definition\_body, return\_type, routine\_description and arguments. | <pre>list(object({<br> routine_id = string,<br> routine_type = string,<br> language = string,<br> definition_body = string,<br> return_type = string,<br> description = string,<br> arguments = list(object({<br> name = string,<br> data_type = string,<br> argument_kind = string,<br> mode = string,<br> })),<br> }))</pre> | `[]` | no |
203205
| tables | A list of objects which include table\_id, table\_name, schema, clustering, time\_partitioning, range\_partitioning, expiration\_time and labels. | <pre>list(object({<br> table_id = string,<br> description = optional(string),<br> table_name = optional(string),<br> schema = string,<br> clustering = list(string),<br> require_partition_filter = optional(bool),<br> time_partitioning = object({<br> expiration_ms = string,<br> field = string,<br> type = string,<br> }),<br> range_partitioning = object({<br> field = string,<br> range = object({<br> start = string,<br> end = string,<br> interval = string,<br> }),<br> }),<br> expiration_time = string,<br> deletion_protection = optional(bool),<br> labels = map(string),<br> }))</pre> | `[]` | no |
204206
| views | A list of objects which include view\_id and view query | <pre>list(object({<br> view_id = string,<br> description = optional(string),<br> query = string,<br> use_legacy_sql = bool,<br> labels = map(string),<br> }))</pre> | `[]` | no |

‎main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ resource "google_bigquery_dataset" "main" {
3838
max_time_travel_hours = var.max_time_travel_hours
3939
project = var.project_id
4040
labels = var.dataset_labels
41+
resource_tags = var.resource_tags
4142

4243
dynamic "default_encryption_configuration" {
4344
for_each = var.encryption_key == null ? [] : [var.encryption_key]

‎metadata.display.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ spec:
6969
project_id:
7070
name: project_id
7171
title: Project Id
72+
resource_tags:
73+
name: resource_tags
74+
title: Resource Tags
7275
routines:
7376
name: routines
7477
title: Routines

‎metadata.yaml

+98-91
Original file line numberDiff line numberDiff line change
@@ -52,78 +52,93 @@ spec:
5252
location: examples/scheduled_queries
5353
interfaces:
5454
variables:
55-
- name: access
56-
description: An array of objects that define dataset access for one or more entities.
57-
varType: any
58-
defaultValue:
59-
- role: roles/bigquery.dataOwner
60-
special_group: projectOwners
6155
- name: dataset_id
6256
description: Unique ID for the dataset being provisioned.
6357
varType: string
6458
required: true
65-
- name: dataset_labels
66-
description: Key value pairs in a map for dataset labels
67-
varType: map(string)
68-
defaultValue: {}
6959
- name: dataset_name
7060
description: Friendly name for the dataset being provisioned.
7161
varType: string
72-
- name: default_table_expiration_ms
73-
description: TTL of tables using the dataset in MS
74-
varType: number
62+
- name: description
63+
description: Dataset description.
64+
varType: string
65+
- name: location
66+
description: The regional location for the dataset only US and EU are allowed in module
67+
varType: string
68+
defaultValue: US
7569
- name: delete_contents_on_destroy
7670
description: (Optional) If set to true, delete all the tables in the dataset when destroying the resource; otherwise, destroying the resource will fail if tables are present.
7771
varType: bool
7872
- name: deletion_protection
7973
description: Whether or not to allow deletion of tables and external tables defined by this module. Can be overriden by table-level deletion_protection configuration.
8074
varType: bool
8175
defaultValue: false
82-
- name: description
83-
description: Dataset description.
76+
- name: default_table_expiration_ms
77+
description: TTL of tables using the dataset in MS
78+
varType: number
79+
- name: max_time_travel_hours
80+
description: Defines the time travel window in hours
81+
varType: number
82+
- name: project_id
83+
description: Project where the dataset and table are created
8484
varType: string
85+
required: true
8586
- name: encryption_key
8687
description: Default encryption key to apply to the dataset. Defaults to null (Google-managed).
8788
varType: string
88-
- name: external_tables
89-
description: A list of objects which include table_id, expiration_time, external_data_configuration, and labels.
89+
- name: dataset_labels
90+
description: Key value pairs in a map for dataset labels
91+
varType: map(string)
92+
defaultValue: {}
93+
- name: resource_tags
94+
description: A map of resource tags to add to the dataset
95+
varType: map(string)
96+
defaultValue: {}
97+
- name: access
98+
description: An array of objects that define dataset access for one or more entities.
99+
varType: any
100+
defaultValue:
101+
- role: roles/bigquery.dataOwner
102+
special_group: projectOwners
103+
- name: tables
104+
description: A list of objects which include table_id, table_name, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels.
90105
varType: |-
91106
list(object({
92-
table_id = string,
93-
description = optional(string),
94-
autodetect = bool,
95-
compression = string,
96-
ignore_unknown_values = bool,
97-
max_bad_records = number,
98-
schema = string,
99-
source_format = string,
100-
source_uris = list(string),
101-
csv_options = object({
102-
quote = string,
103-
allow_jagged_rows = bool,
104-
allow_quoted_newlines = bool,
105-
encoding = string,
106-
field_delimiter = string,
107-
skip_leading_rows = number,
108-
}),
109-
google_sheets_options = object({
110-
range = string,
111-
skip_leading_rows = number,
107+
table_id = string,
108+
description = optional(string),
109+
table_name = optional(string),
110+
schema = string,
111+
clustering = list(string),
112+
require_partition_filter = optional(bool),
113+
time_partitioning = object({
114+
expiration_ms = string,
115+
field = string,
116+
type = string,
112117
}),
113-
hive_partitioning_options = object({
114-
mode = string,
115-
source_uri_prefix = string,
118+
range_partitioning = object({
119+
field = string,
120+
range = object({
121+
start = string,
122+
end = string,
123+
interval = string,
124+
}),
116125
}),
117126
expiration_time = string,
118-
max_staleness = optional(string),
119127
deletion_protection = optional(bool),
120128
labels = map(string),
121129
}))
122130
defaultValue: []
123-
- name: location
124-
description: The regional location for the dataset only US and EU are allowed in module
125-
varType: string
126-
defaultValue: US
131+
- name: views
132+
description: A list of objects which include view_id and view query
133+
varType: |-
134+
list(object({
135+
view_id = string,
136+
description = optional(string),
137+
query = string,
138+
use_legacy_sql = bool,
139+
labels = map(string),
140+
}))
141+
defaultValue: []
127142
- name: materialized_views
128143
description: A list of objects which includes view_id, view_query, clustering, time_partitioning, range_partitioning, expiration_time and labels
129144
varType: |-
@@ -153,13 +168,41 @@ spec:
153168
labels = map(string),
154169
}))
155170
defaultValue: []
156-
- name: max_time_travel_hours
157-
description: Defines the time travel window in hours
158-
varType: number
159-
- name: project_id
160-
description: Project where the dataset and table are created
161-
varType: string
162-
required: true
171+
- name: external_tables
172+
description: A list of objects which include table_id, expiration_time, external_data_configuration, and labels.
173+
varType: |-
174+
list(object({
175+
table_id = string,
176+
description = optional(string),
177+
autodetect = bool,
178+
compression = string,
179+
ignore_unknown_values = bool,
180+
max_bad_records = number,
181+
schema = string,
182+
source_format = string,
183+
source_uris = list(string),
184+
csv_options = object({
185+
quote = string,
186+
allow_jagged_rows = bool,
187+
allow_quoted_newlines = bool,
188+
encoding = string,
189+
field_delimiter = string,
190+
skip_leading_rows = number,
191+
}),
192+
google_sheets_options = object({
193+
range = string,
194+
skip_leading_rows = number,
195+
}),
196+
hive_partitioning_options = object({
197+
mode = string,
198+
source_uri_prefix = string,
199+
}),
200+
expiration_time = string,
201+
max_staleness = optional(string),
202+
deletion_protection = optional(bool),
203+
labels = map(string),
204+
}))
205+
defaultValue: []
163206
- name: routines
164207
description: A list of objects which include routine_id, routine_type, routine_language, definition_body, return_type, routine_description and arguments.
165208
varType: |-
@@ -178,45 +221,6 @@ spec:
178221
})),
179222
}))
180223
defaultValue: []
181-
- name: tables
182-
description: A list of objects which include table_id, table_name, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels.
183-
varType: |-
184-
list(object({
185-
table_id = string,
186-
description = optional(string),
187-
table_name = optional(string),
188-
schema = string,
189-
clustering = list(string),
190-
require_partition_filter = optional(bool),
191-
time_partitioning = object({
192-
expiration_ms = string,
193-
field = string,
194-
type = string,
195-
}),
196-
range_partitioning = object({
197-
field = string,
198-
range = object({
199-
start = string,
200-
end = string,
201-
interval = string,
202-
}),
203-
}),
204-
expiration_time = string,
205-
deletion_protection = optional(bool),
206-
labels = map(string),
207-
}))
208-
defaultValue: []
209-
- name: views
210-
description: A list of objects which include view_id and view query
211-
varType: |-
212-
list(object({
213-
view_id = string,
214-
description = optional(string),
215-
query = string,
216-
use_legacy_sql = bool,
217-
labels = map(string),
218-
}))
219-
defaultValue: []
220224
outputs:
221225
- name: bigquery_dataset
222226
description: Bigquery dataset resource.
@@ -257,3 +261,6 @@ spec:
257261
- bigqueryconnection.googleapis.com
258262
- serviceusage.googleapis.com
259263
- iam.googleapis.com
264+
providerVersions:
265+
- source: hashicorp/google
266+
version: ">= 5.39, < 7"

‎modules/authorization/metadata.yaml

+24-21
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,27 @@ spec:
4444
location: examples/scheduled_queries
4545
interfaces:
4646
variables:
47+
- name: dataset_id
48+
description: Unique ID for the dataset being provisioned.
49+
varType: string
50+
required: true
51+
- name: project_id
52+
description: Project where the dataset and table are created
53+
varType: string
54+
required: true
55+
- name: roles
56+
description: An array of objects that define dataset access for one or more entities.
57+
varType: any
58+
defaultValue: []
59+
- name: authorized_views
60+
description: An array of views to give authorize for the dataset
61+
varType: |-
62+
list(object({
63+
dataset_id = string,
64+
project_id = string,
65+
table_id = string # this is the view id, but we keep table_id to stay consistent as the resource
66+
}))
67+
defaultValue: []
4768
- name: authorized_datasets
4869
description: An array of datasets to be authorized on the dataset
4970
varType: |-
@@ -61,27 +82,6 @@ spec:
6182
routine_id = string
6283
}))
6384
defaultValue: []
64-
- name: authorized_views
65-
description: An array of views to give authorize for the dataset
66-
varType: |-
67-
list(object({
68-
dataset_id = string,
69-
project_id = string,
70-
table_id = string # this is the view id, but we keep table_id to stay consistent as the resource
71-
}))
72-
defaultValue: []
73-
- name: dataset_id
74-
description: Unique ID for the dataset being provisioned.
75-
varType: string
76-
required: true
77-
- name: project_id
78-
description: Project where the dataset and table are created
79-
varType: string
80-
required: true
81-
- name: roles
82-
description: An array of objects that define dataset access for one or more entities.
83-
varType: any
84-
defaultValue: []
8585
outputs:
8686
- name: authorized_dataset
8787
description: Authorized datasets for the BQ dataset
@@ -104,3 +104,6 @@ spec:
104104
- bigqueryconnection.googleapis.com
105105
- serviceusage.googleapis.com
106106
- iam.googleapis.com
107+
providerVersions:
108+
- source: hashicorp/google
109+
version: ">= 5.39, < 7"

‎modules/data_warehouse/metadata.yaml

+24-21
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,26 @@ spec:
7777
location: examples/scheduled_queries
7878
interfaces:
7979
variables:
80-
- name: create_ignore_service_accounts
81-
description: Whether or not to ignore creation of a service account if an account of the same name already exists
80+
- name: project_id
81+
description: Google Cloud Project ID
8282
varType: string
83-
defaultValue: true
83+
required: true
84+
- name: region
85+
description: Google Cloud Region
86+
varType: string
87+
required: true
8488
- name: dataform_region
8589
description: Region that is used to deploy Dataform resources. This does not limit where resources can be run or what region data must be located in.
8690
varType: string
87-
- name: deletion_protection
88-
description: Whether or not to protect GCS resources from deletion when solution is modified or changed.
91+
- name: text_generation_model_name
92+
description: Name of the BigQuery ML GenAI remote model that connects to the LLM used for text generation
8993
varType: string
90-
defaultValue: false
94+
defaultValue: text_generate_model
95+
- name: labels
96+
description: A map of labels to apply to contained resources.
97+
varType: map(string)
98+
defaultValue:
99+
data-warehouse: true
91100
- name: enable_apis
92101
description: Whether or not to enable underlying apis in this solution.
93102
varType: string
@@ -96,23 +105,14 @@ spec:
96105
description: Whether or not to protect BigQuery resources from deletion when solution is modified or changed.
97106
varType: string
98107
defaultValue: true
99-
- name: labels
100-
description: A map of labels to apply to contained resources.
101-
varType: map(string)
102-
defaultValue:
103-
data-warehouse: true
104-
- name: project_id
105-
description: Google Cloud Project ID
106-
varType: string
107-
required: true
108-
- name: region
109-
description: Google Cloud Region
108+
- name: deletion_protection
109+
description: Whether or not to protect GCS resources from deletion when solution is modified or changed.
110110
varType: string
111-
required: true
112-
- name: text_generation_model_name
113-
description: Name of the BigQuery ML GenAI remote model that connects to the LLM used for text generation
111+
defaultValue: false
112+
- name: create_ignore_service_accounts
113+
description: Whether or not to ignore creation of a service account if an account of the same name already exists
114114
varType: string
115-
defaultValue: text_generate_model
115+
defaultValue: true
116116
outputs:
117117
- name: bigquery_editor_url
118118
description: The URL to launch the BigQuery editor with the sample query procedure opened
@@ -139,3 +139,6 @@ spec:
139139
- bigqueryconnection.googleapis.com
140140
- serviceusage.googleapis.com
141141
- iam.googleapis.com
142+
providerVersions:
143+
- source: hashicorp/google
144+
version: ">= 5.39, < 7"

‎modules/scheduled_queries/metadata.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ spec:
7070
- bigqueryconnection.googleapis.com
7171
- serviceusage.googleapis.com
7272
- iam.googleapis.com
73+
providerVersions:
74+
- source: hashicorp/google
75+
version: ">= 5.39, < 7"

‎modules/udf/metadata.yaml

+7-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ spec:
4444
location: examples/scheduled_queries
4545
interfaces:
4646
variables:
47-
- name: add_udfs
48-
description: Whether or not this module should be enabled.
49-
varType: string
50-
defaultValue: false
5147
- name: dataset_id
5248
description: Dataset id
5349
varType: string
@@ -56,6 +52,10 @@ spec:
5652
description: Project ID that contains the dataset
5753
varType: string
5854
required: true
55+
- name: add_udfs
56+
description: Whether or not this module should be enabled.
57+
varType: string
58+
defaultValue: false
5959
outputs:
6060
- name: added_udfs
6161
description: List of UDFs utility functions added.
@@ -74,3 +74,6 @@ spec:
7474
- bigqueryconnection.googleapis.com
7575
- serviceusage.googleapis.com
7676
- iam.googleapis.com
77+
providerVersions:
78+
- source: hashicorp/google
79+
version: ">= 5.39, < 7"

‎variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ variable "dataset_labels" {
7878
default = {}
7979
}
8080

81+
variable "resource_tags" {
82+
description = "A map of resource tags to add to the dataset"
83+
type = map(string)
84+
default = {}
85+
}
86+
8187
# Format: list(objects)
8288
# domain: A domain to grant access to.
8389
# group_by_email: An email address of a Google Group to grant access to.

‎versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020

2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 5.3, < 7"
23+
version = ">= 5.39, < 7"
2424
}
2525
}
2626

0 commit comments

Comments
 (0)
Please sign in to comment.