diff --git a/.tool-versions b/.tool-versions index 64eb57b..8f3b082 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,4 @@ terraform 1.5.7 -terramate 0.4.5 +terramate 0.11.2 tflint 0.50.2 pre-commit 3.6.1 diff --git a/README.md b/README.md index cf2b9ef..f96de4f 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,36 @@ See [variables.tf] and [examples/] for details and use-cases. Default is `{}`. +- [**`resource_tags`**](#var-resource_tags): *(Optional `any`)* + + The tags attached to this table. Tag keys are globally unique. + Tag key is expected to be in the namespaced format, for example "123456789012/environment" + where 123456789012 is the ID of the parent organization or project resource for this tag key. + Tag value is expected to be the short name, for example "Production". + + Default is `null`. + +- [**`max_time_travel_hours`**](#var-max_time_travel_hours): *(Optional `number`)* + + Defines the time travel window in hours. The value can be from 48 to 168 hours (2 to 7 days). + + Default is `null`. + +- [**`external_dataset_reference`**](#var-external_dataset_reference): *(Optional `any`)* + + Information about the external metadata storage where the dataset is defined." + Supported attributes: + - external_source - (Required) External source that backs this dataset. + - connection - (Required) The connection id that is used to access the externalSource. Format: projects/{projectId}/locations/{locationId}/connections/{connectionId} + + Default is `null`. + +- [**`is_case_insensitive`**](#var-is_case_insensitive): *(Optional `bool`)* + + TRUE if the dataset and its table names are case-insensitive, otherwise FALSE. By default, this is FALSE, which means the dataset and its table names are case-sensitive. This field does not affect routine references. + + Default is `false`. + - [**`access`**](#var-access): *(Optional `list(access)`)* An array of objects that define dataset access for one or more entities. diff --git a/README.tfdoc.hcl b/README.tfdoc.hcl index b7e5f29..cbd6b4c 100644 --- a/README.tfdoc.hcl +++ b/README.tfdoc.hcl @@ -143,6 +143,40 @@ section { END } + variable "resource_tags" { + type = any + default = null + description = <<-END + The tags attached to this table. Tag keys are globally unique. + Tag key is expected to be in the namespaced format, for example "123456789012/environment" + where 123456789012 is the ID of the parent organization or project resource for this tag key. + Tag value is expected to be the short name, for example "Production". + END + } + + variable "max_time_travel_hours" { + description = "Defines the time travel window in hours. The value can be from 48 to 168 hours (2 to 7 days)." + type = number + default = null + } + + variable "external_dataset_reference" { + type = any + default = null + description = <<-END + Information about the external metadata storage where the dataset is defined." + Supported attributes: + - external_source - (Required) External source that backs this dataset. + - connection - (Required) The connection id that is used to access the externalSource. Format: projects/{projectId}/locations/{locationId}/connections/{connectionId} + END + } + + variable "is_case_insensitive" { + description = "TRUE if the dataset and its table names are case-insensitive, otherwise FALSE. By default, this is FALSE, which means the dataset and its table names are case-sensitive. This field does not affect routine references." + type = bool + default = false + } + variable "access" { type = list(access) readme_type = "list(access)" diff --git a/iam.tf b/iam.tf index 16229d0..e6e60cd 100644 --- a/iam.tf +++ b/iam.tf @@ -3,7 +3,7 @@ locals { } module "iam" { - source = "github.com/mineiros-io/terraform-google-bigquery-dataset-iam?ref=v0.1.0" + source = "github.com/mineiros-io/terraform-google-bigquery-dataset-iam?ref=v0.2.0" for_each = local.iam_map diff --git a/main.tf b/main.tf index 94f301f..2051749 100644 --- a/main.tf +++ b/main.tf @@ -6,12 +6,15 @@ resource "google_bigquery_dataset" "dataset" { dataset_id = var.dataset_id default_table_expiration_ms = var.default_table_expiration_ms default_partition_expiration_ms = var.default_partition_expiration_ms + max_time_travel_hours = var.max_time_travel_hours + is_case_insensitive = var.is_case_insensitive description = var.description friendly_name = var.friendly_name project = var.project location = var.location delete_contents_on_destroy = var.delete_contents_on_destroy labels = var.labels + resource_tags = var.resource_tags dynamic "access" { for_each = toset(var.access) @@ -44,4 +47,13 @@ resource "google_bigquery_dataset" "dataset" { } } + dynamic "external_dataset_reference" { + for_each = var.external_dataset_reference == null ? [] : [var.external_dataset_reference] + + content { + external_source = external_dataset_reference.value.external_source + connection = external_dataset_reference.value.connection + } + } + } diff --git a/test/terramate_provider_versions.tm.hcl b/test/terramate_provider_versions.tm.hcl index f5168c1..73c89b8 100644 --- a/test/terramate_provider_versions.tm.hcl +++ b/test/terramate_provider_versions.tm.hcl @@ -1,5 +1,5 @@ globals { provider = "google" - minimum_provider_version = "4.0" - provider_version_constraint = "~> ${global.minimum_provider_version}" + minimum_provider_version = "5.39" + provider_version_constraint = "~> 6.0" } diff --git a/test/unit-complete/_generated_google.tf b/test/unit-complete/_generated_google.tf index b1301be..0b816e9 100644 --- a/test/unit-complete/_generated_google.tf +++ b/test/unit-complete/_generated_google.tf @@ -24,11 +24,11 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = "~> 4.0" + version = "~> 6.0" } google-beta = { source = "hashicorp/google-beta" - version = "~> 4.0" + version = "~> 6.0" } random = { source = "hashicorp/random" diff --git a/test/unit-complete/main.tf b/test/unit-complete/main.tf index 71e4558..79e465a 100644 --- a/test/unit-complete/main.tf +++ b/test/unit-complete/main.tf @@ -14,6 +14,19 @@ module "test" { env = "default" } + resource_tags = { + "key" : "value", + "key2" : "value2", + } + + external_dataset_reference = { + external_source = "aws-glue://arn:aws:glue:us-east-1:999999999999:database/database" + connection = "projects/project/locations/aws-us-east-1/connections/connection" + } + + is_case_insensitive = false + max_time_travel_hours = 48 + access = [ { role = "roles/browser" diff --git a/test/unit-disabled/_generated_google.tf b/test/unit-disabled/_generated_google.tf index 34ef683..40aa9dd 100644 --- a/test/unit-disabled/_generated_google.tf +++ b/test/unit-disabled/_generated_google.tf @@ -24,11 +24,11 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = "~> 4.0" + version = "~> 6.0" } google-beta = { source = "hashicorp/google-beta" - version = "~> 4.0" + version = "~> 6.0" } random = { source = "hashicorp/random" diff --git a/test/unit-minimal/_generated_google.tf b/test/unit-minimal/_generated_google.tf index c71020d..df0f695 100644 --- a/test/unit-minimal/_generated_google.tf +++ b/test/unit-minimal/_generated_google.tf @@ -24,11 +24,11 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = "4.0" + version = "5.39" } google-beta = { source = "hashicorp/google-beta" - version = "4.0" + version = "5.39" } random = { source = "hashicorp/random" diff --git a/test/unit-minimal/stack.tm.hcl b/test/unit-minimal/stack.tm.hcl index 2872a9b..10a3620 100644 --- a/test/unit-minimal/stack.tm.hcl +++ b/test/unit-minimal/stack.tm.hcl @@ -6,7 +6,7 @@ stack { EOD } -# in this stack we want to test the exact minimum provider version so let's set contraint accodingly +# in this stack we want to test the exact minimum provider version so let's set constraint accordingly globals { provider_version_constraint = global.minimum_provider_version } diff --git a/variables.tf b/variables.tf index abd7349..b02e2d5 100644 --- a/variables.tf +++ b/variables.tf @@ -65,6 +65,34 @@ variable "labels" { default = {} } +variable "max_time_travel_hours" { + description = "(Optional) Defines the time travel window in hours. The value can be from 48 to 168 hours (2 to 7 days)." + type = number + default = null +} + +variable "external_dataset_reference" { + description = "(Optional) Information about the external metadata storage where the dataset is defined." + type = any + default = null + + ## Attributes: + # external_source - (Required) External source that backs this dataset. + # connection - (Required) The connection id that is used to access the externalSource. Format: projects/{projectId}/locations/{locationId}/connections/{connectionId} +} + +variable "is_case_insensitive" { + description = "(Optional) TRUE if the dataset and its table names are case-insensitive, otherwise FALSE. By default, this is FALSE, which means the dataset and its table names are case-sensitive. This field does not affect routine references." + type = bool + default = false +} + +variable "resource_tags" { + description = "(Optional) The tags attached to this table. Tag keys are globally unique. Tag key is expected to be in the namespaced format, for example \"123456789012/environment\" where 123456789012 is the ID of the parent organization or project resource for this tag key. Tag value is expected to be the short name, for example \"Production\"." + type = any + default = null +} + variable "access" { # type = list(object({ # #(Optional) A domain to grant access to. Any users signed in with the domain specified will be granted the specified access diff --git a/versions.tf b/versions.tf index c2d1f64..8dc60da 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = ">= 4.0, <6" + version = ">= 5.39, <7" } } }