Skip to content

Commit 53646de

Browse files
SamuZadSamPoole
andauthored
feat: add storage_billing_model and default_partition_expiration_ms (#367)
Co-authored-by: Sam Poole <[email protected]>
1 parent 7233527 commit 53646de

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ This module provisions a dataset and a list of tables with associated JSON schem
190190
| dataset\_id | Unique ID for the dataset being provisioned. | `string` | n/a | yes |
191191
| dataset\_labels | Key value pairs in a map for dataset labels | `map(string)` | `{}` | no |
192192
| dataset\_name | Friendly name for the dataset being provisioned. | `string` | `null` | no |
193+
| default\_partition\_expiration\_ms | The default partition expiration for all partitioned tables in the dataset, in MS | `number` | `null` | no |
193194
| default\_table\_expiration\_ms | TTL of tables using the dataset in MS | `number` | `null` | no |
194195
| delete\_contents\_on\_destroy | (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. | `bool` | `null` | no |
195196
| deletion\_protection | Whether or not to allow deletion of tables and external tables defined by this module. Can be overriden by table-level deletion\_protection configuration. | `bool` | `false` | no |
@@ -202,6 +203,7 @@ This module provisions a dataset and a list of tables with associated JSON schem
202203
| project\_id | Project where the dataset and table are created | `string` | n/a | yes |
203204
| resource\_tags | A map of resource tags to add to the dataset | `map(string)` | `{}` | no |
204205
| 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 |
206+
| storage\_billing\_model | Specifies the storage billing model for the dataset. Set this flag value to LOGICAL to use logical bytes for storage billing, or to PHYSICAL to use physical bytes instead. LOGICAL is the default if this flag isn't specified. | `string` | `null` | no |
205207
| 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 |
206208
| 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 |
207209

main.tf

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ locals {
2929
}
3030

3131
resource "google_bigquery_dataset" "main" {
32-
dataset_id = var.dataset_id
33-
friendly_name = var.dataset_name
34-
description = var.description
35-
location = var.location
36-
delete_contents_on_destroy = var.delete_contents_on_destroy
37-
default_table_expiration_ms = var.default_table_expiration_ms
38-
max_time_travel_hours = var.max_time_travel_hours
39-
project = var.project_id
40-
labels = var.dataset_labels
41-
resource_tags = var.resource_tags
32+
dataset_id = var.dataset_id
33+
friendly_name = var.dataset_name
34+
description = var.description
35+
location = var.location
36+
delete_contents_on_destroy = var.delete_contents_on_destroy
37+
default_table_expiration_ms = var.default_table_expiration_ms
38+
max_time_travel_hours = var.max_time_travel_hours
39+
storage_billing_model = var.storage_billing_model
40+
project = var.project_id
41+
labels = var.dataset_labels
42+
resource_tags = var.resource_tags
43+
default_partition_expiration_ms = var.default_partition_expiration_ms
4244

4345
dynamic "default_encryption_configuration" {
4446
for_each = var.encryption_key == null ? [] : [var.encryption_key]

metadata.display.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ spec:
3939
dataset_name:
4040
name: dataset_name
4141
title: Dataset Name
42+
default_partition_expiration_ms:
43+
name: default_partition_expiration_ms
44+
title: Default Partition Expiration Ms
4245
default_table_expiration_ms:
4346
name: default_table_expiration_ms
4447
title: Default Table Expiration Ms
@@ -75,6 +78,9 @@ spec:
7578
routines:
7679
name: routines
7780
title: Routines
81+
storage_billing_model:
82+
name: storage_billing_model
83+
title: Storage Billing Model
7884
tables:
7985
name: tables
8086
title: Tables

metadata.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ spec:
7676
- name: default_table_expiration_ms
7777
description: TTL of tables using the dataset in MS
7878
varType: number
79+
- name: default_partition_expiration_ms
80+
description: The default partition expiration for all partitioned tables in the dataset, in MS
81+
varType: number
7982
- name: max_time_travel_hours
8083
description: Defines the time travel window in hours
8184
varType: number
85+
- name: storage_billing_model
86+
description: Specifies the storage billing model for the dataset. Set this flag value to LOGICAL to use logical bytes for storage billing, or to PHYSICAL to use physical bytes instead. LOGICAL is the default if this flag isn't specified.
87+
varType: string
8288
- name: project_id
8389
description: Project where the dataset and table are created
8490
varType: string

variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,29 @@ variable "default_table_expiration_ms" {
5555
default = null
5656
}
5757

58+
variable "default_partition_expiration_ms" {
59+
description = "The default partition expiration for all partitioned tables in the dataset, in MS"
60+
type = number
61+
default = null
62+
}
63+
5864
variable "max_time_travel_hours" {
5965
description = "Defines the time travel window in hours"
6066
type = number
6167
default = null
6268
}
6369

70+
variable "storage_billing_model" {
71+
description = "Specifies the storage billing model for the dataset. Set this flag value to LOGICAL to use logical bytes for storage billing, or to PHYSICAL to use physical bytes instead. LOGICAL is the default if this flag isn't specified."
72+
type = string
73+
default = null
74+
75+
validation {
76+
condition = var.storage_billing_model == null || var.storage_billing_model == "LOGICAL" || var.storage_billing_model == "PHYSICAL"
77+
error_message = "storage_billing_model must be null, \"LOGICAL\" or \"PHYSICAL\"."
78+
}
79+
}
80+
6481
variable "project_id" {
6582
description = "Project where the dataset and table are created"
6683
type = string

0 commit comments

Comments
 (0)