Skip to content

Commit

Permalink
feature(TPG>=5.39)!: add resource_tags (#354)
Browse files Browse the repository at this point in the history
Co-authored-by: Anuj Rohilla <[email protected]>
Co-authored-by: Anuj Rohilla <[email protected]>
  • Loading branch information
3 people authored Oct 16, 2024
1 parent a96a593 commit c07d42e
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 138 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module "bigquery" {
project_id = "<PROJECT ID>"
location = "US"
default_table_expiration_ms = 3600000
resource_tags = {"<PROJECT>/<TAG KEY>":"<TAG VALUE>"}
tables = [
{
Expand Down Expand Up @@ -199,6 +200,7 @@ This module provisions a dataset and a list of tables with associated JSON schem
| 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 |
| max\_time\_travel\_hours | Defines the time travel window in hours | `number` | `null` | no |
| project\_id | Project where the dataset and table are created | `string` | n/a | yes |
| resource\_tags | A map of resource tags to add to the dataset | `map(string)` | `{}` | no |
| 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 |
| 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 |
| 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 |
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "google_bigquery_dataset" "main" {
max_time_travel_hours = var.max_time_travel_hours
project = var.project_id
labels = var.dataset_labels
resource_tags = var.resource_tags

dynamic "default_encryption_configuration" {
for_each = var.encryption_key == null ? [] : [var.encryption_key]
Expand Down
3 changes: 3 additions & 0 deletions metadata.display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ spec:
project_id:
name: project_id
title: Project Id
resource_tags:
name: resource_tags
title: Resource Tags
routines:
name: routines
title: Routines
Expand Down
189 changes: 98 additions & 91 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,78 +52,93 @@ spec:
location: examples/scheduled_queries
interfaces:
variables:
- name: access
description: An array of objects that define dataset access for one or more entities.
varType: any
defaultValue:
- role: roles/bigquery.dataOwner
special_group: projectOwners
- name: dataset_id
description: Unique ID for the dataset being provisioned.
varType: string
required: true
- name: dataset_labels
description: Key value pairs in a map for dataset labels
varType: map(string)
defaultValue: {}
- name: dataset_name
description: Friendly name for the dataset being provisioned.
varType: string
- name: default_table_expiration_ms
description: TTL of tables using the dataset in MS
varType: number
- name: description
description: Dataset description.
varType: string
- name: location
description: The regional location for the dataset only US and EU are allowed in module
varType: string
defaultValue: US
- name: delete_contents_on_destroy
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.
varType: bool
- name: deletion_protection
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.
varType: bool
defaultValue: false
- name: description
description: Dataset description.
- name: default_table_expiration_ms
description: TTL of tables using the dataset in MS
varType: number
- name: max_time_travel_hours
description: Defines the time travel window in hours
varType: number
- name: project_id
description: Project where the dataset and table are created
varType: string
required: true
- name: encryption_key
description: Default encryption key to apply to the dataset. Defaults to null (Google-managed).
varType: string
- name: external_tables
description: A list of objects which include table_id, expiration_time, external_data_configuration, and labels.
- name: dataset_labels
description: Key value pairs in a map for dataset labels
varType: map(string)
defaultValue: {}
- name: resource_tags
description: A map of resource tags to add to the dataset
varType: map(string)
defaultValue: {}
- name: access
description: An array of objects that define dataset access for one or more entities.
varType: any
defaultValue:
- role: roles/bigquery.dataOwner
special_group: projectOwners
- name: tables
description: A list of objects which include table_id, table_name, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels.
varType: |-
list(object({
table_id = string,
description = optional(string),
autodetect = bool,
compression = string,
ignore_unknown_values = bool,
max_bad_records = number,
schema = string,
source_format = string,
source_uris = list(string),
csv_options = object({
quote = string,
allow_jagged_rows = bool,
allow_quoted_newlines = bool,
encoding = string,
field_delimiter = string,
skip_leading_rows = number,
}),
google_sheets_options = object({
range = string,
skip_leading_rows = number,
table_id = string,
description = optional(string),
table_name = optional(string),
schema = string,
clustering = list(string),
require_partition_filter = optional(bool),
time_partitioning = object({
expiration_ms = string,
field = string,
type = string,
}),
hive_partitioning_options = object({
mode = string,
source_uri_prefix = string,
range_partitioning = object({
field = string,
range = object({
start = string,
end = string,
interval = string,
}),
}),
expiration_time = string,
max_staleness = optional(string),
deletion_protection = optional(bool),
labels = map(string),
}))
defaultValue: []
- name: location
description: The regional location for the dataset only US and EU are allowed in module
varType: string
defaultValue: US
- name: views
description: A list of objects which include view_id and view query
varType: |-
list(object({
view_id = string,
description = optional(string),
query = string,
use_legacy_sql = bool,
labels = map(string),
}))
defaultValue: []
- name: materialized_views
description: A list of objects which includes view_id, view_query, clustering, time_partitioning, range_partitioning, expiration_time and labels
varType: |-
Expand Down Expand Up @@ -153,13 +168,41 @@ spec:
labels = map(string),
}))
defaultValue: []
- name: max_time_travel_hours
description: Defines the time travel window in hours
varType: number
- name: project_id
description: Project where the dataset and table are created
varType: string
required: true
- name: external_tables
description: A list of objects which include table_id, expiration_time, external_data_configuration, and labels.
varType: |-
list(object({
table_id = string,
description = optional(string),
autodetect = bool,
compression = string,
ignore_unknown_values = bool,
max_bad_records = number,
schema = string,
source_format = string,
source_uris = list(string),
csv_options = object({
quote = string,
allow_jagged_rows = bool,
allow_quoted_newlines = bool,
encoding = string,
field_delimiter = string,
skip_leading_rows = number,
}),
google_sheets_options = object({
range = string,
skip_leading_rows = number,
}),
hive_partitioning_options = object({
mode = string,
source_uri_prefix = string,
}),
expiration_time = string,
max_staleness = optional(string),
deletion_protection = optional(bool),
labels = map(string),
}))
defaultValue: []
- name: routines
description: A list of objects which include routine_id, routine_type, routine_language, definition_body, return_type, routine_description and arguments.
varType: |-
Expand All @@ -178,45 +221,6 @@ spec:
})),
}))
defaultValue: []
- name: tables
description: A list of objects which include table_id, table_name, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels.
varType: |-
list(object({
table_id = string,
description = optional(string),
table_name = optional(string),
schema = string,
clustering = list(string),
require_partition_filter = optional(bool),
time_partitioning = object({
expiration_ms = string,
field = string,
type = string,
}),
range_partitioning = object({
field = string,
range = object({
start = string,
end = string,
interval = string,
}),
}),
expiration_time = string,
deletion_protection = optional(bool),
labels = map(string),
}))
defaultValue: []
- name: views
description: A list of objects which include view_id and view query
varType: |-
list(object({
view_id = string,
description = optional(string),
query = string,
use_legacy_sql = bool,
labels = map(string),
}))
defaultValue: []
outputs:
- name: bigquery_dataset
description: Bigquery dataset resource.
Expand Down Expand Up @@ -257,3 +261,6 @@ spec:
- bigqueryconnection.googleapis.com
- serviceusage.googleapis.com
- iam.googleapis.com
providerVersions:
- source: hashicorp/google
version: ">= 5.39, < 7"
45 changes: 24 additions & 21 deletions modules/authorization/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ spec:
location: examples/scheduled_queries
interfaces:
variables:
- name: dataset_id
description: Unique ID for the dataset being provisioned.
varType: string
required: true
- name: project_id
description: Project where the dataset and table are created
varType: string
required: true
- name: roles
description: An array of objects that define dataset access for one or more entities.
varType: any
defaultValue: []
- name: authorized_views
description: An array of views to give authorize for the dataset
varType: |-
list(object({
dataset_id = string,
project_id = string,
table_id = string # this is the view id, but we keep table_id to stay consistent as the resource
}))
defaultValue: []
- name: authorized_datasets
description: An array of datasets to be authorized on the dataset
varType: |-
Expand All @@ -61,27 +82,6 @@ spec:
routine_id = string
}))
defaultValue: []
- name: authorized_views
description: An array of views to give authorize for the dataset
varType: |-
list(object({
dataset_id = string,
project_id = string,
table_id = string # this is the view id, but we keep table_id to stay consistent as the resource
}))
defaultValue: []
- name: dataset_id
description: Unique ID for the dataset being provisioned.
varType: string
required: true
- name: project_id
description: Project where the dataset and table are created
varType: string
required: true
- name: roles
description: An array of objects that define dataset access for one or more entities.
varType: any
defaultValue: []
outputs:
- name: authorized_dataset
description: Authorized datasets for the BQ dataset
Expand All @@ -104,3 +104,6 @@ spec:
- bigqueryconnection.googleapis.com
- serviceusage.googleapis.com
- iam.googleapis.com
providerVersions:
- source: hashicorp/google
version: ">= 5.39, < 7"
Loading

0 comments on commit c07d42e

Please sign in to comment.