Skip to content

Commit

Permalink
Merge pull request #20 from mineiros-io/zied/upgrade-provider-version
Browse files Browse the repository at this point in the history
feat!: add support for google provider version 6.x and drop 4.x
  • Loading branch information
zied-elouaer authored Nov 21, 2024
2 parents 43d0f8d + 60d5b41 commit 83be6ba
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,36 @@ See [variables.tf] and [examples/] for details and use-cases.

Default is `{}`.

- [**`resource_tags`**](#var-resource_tags): *(Optional `any`)*<a name="var-resource_tags"></a>

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`)*<a name="var-max_time_travel_hours"></a>

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`)*<a name="var-external_dataset_reference"></a>

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`)*<a name="var-is_case_insensitive"></a>

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)`)*<a name="var-access"></a>

An array of objects that define dataset access for one or more entities.
Expand Down
34 changes: 34 additions & 0 deletions README.tfdoc.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}

}
4 changes: 2 additions & 2 deletions test/terramate_provider_versions.tm.hcl
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 2 additions & 2 deletions test/unit-complete/_generated_google.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions test/unit-complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/unit-disabled/_generated_google.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/unit-minimal/_generated_google.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/unit-minimal/stack.tm.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
28 changes: 28 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.0, <6"
version = ">= 5.39, <7"
}
}
}

0 comments on commit 83be6ba

Please sign in to comment.