-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from drandell/assets
add assets module and example
- Loading branch information
Showing
17 changed files
with
279 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ module "google_dataplex" { | |
location = var.location | ||
lakes = var.lakes | ||
zones = var.zones | ||
assets = var.assets | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
output "asset_self_links" { | ||
value = module.google_dataplex.asset_self_links | ||
description = "Map of self links to the defined Dataplex assets" | ||
} | ||
|
||
output "asset_uids" { | ||
value = module.google_dataplex.asset_uids | ||
description = "Map of UIDs to the defined Dataplex assets" | ||
} | ||
|
||
output "lake_self_links" { | ||
value = module.google_dataplex.lake_self_links | ||
value = module.google_dataplex.lake_self_links | ||
description = "Map of self links to the defined Dataplex lakes" | ||
} | ||
|
||
output "lake_uids" { | ||
value = module.google_dataplex.lake_uids | ||
value = module.google_dataplex.lake_uids | ||
description = "Map of UIDs to the defined Dataplex lakes" | ||
} | ||
|
||
output "zone_self_links" { | ||
value = module.google_dataplex.zone_self_links | ||
value = module.google_dataplex.zone_self_links | ||
description = "Map of self links to the defined Dataplex zones" | ||
} | ||
|
||
output "zone_uids" { | ||
value = module.google_dataplex.zone_uids | ||
value = module.google_dataplex.zone_uids | ||
description = "Map of UIDs to the defined Dataplex zones" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
locals { | ||
assets = { for asset in var.assets : asset["id"] => asset } | ||
} | ||
|
||
resource "google_dataplex_asset" "this" { | ||
for_each = local.assets | ||
|
||
location = var.location | ||
project = var.project | ||
lake = var.lake_self_links[each.value["lake_id"]] | ||
dataplex_zone = var.zone_self_links[each.value["zone_id"]] | ||
|
||
name = each.key | ||
description = each.value["description"] | ||
display_name = each.value["display_name"] | ||
labels = each.value["labels"] | ||
|
||
discovery_spec { | ||
enabled = each.value["discovery_spec"]["enabled"] | ||
include_patterns = each.value["discovery_spec"]["include_patterns"] | ||
exclude_patterns = each.value["discovery_spec"]["exclude_patterns"] | ||
schedule = each.value["discovery_spec"]["schedule"] | ||
|
||
dynamic "csv_options" { | ||
for_each = each.value["discovery_spec"]["csv_options"] != null ? { "csv_opt" : each.value["discovery_spec"]["csv_options"] } : {} | ||
content { | ||
delimiter = csv_options.value["delimiter"] | ||
header_rows = csv_options.value["header_rows"] | ||
disable_type_inference = csv_options.value["disable_type_inference"] | ||
encoding = csv_options.value["encoding"] | ||
} | ||
} | ||
|
||
dynamic "json_options" { | ||
for_each = each.value["discovery_spec"]["json_options"] != null ? { "json_opt" : each.value["discovery_spec"]["json_options"] } : {} | ||
content { | ||
disable_type_inference = json_options.value["disable_type_inference"] | ||
encoding = json_options.value["encoding"] | ||
} | ||
} | ||
} | ||
|
||
resource_spec { | ||
name = each.value["resource_spec"]["name"] | ||
type = each.value["resource_spec"]["type"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "self_links" { | ||
value = { for key, asset in google_dataplex_asset.this : key => asset.id } | ||
description = "Map of self links of our defined assets" | ||
} | ||
|
||
output "uids" { | ||
value = { for key, asset in google_dataplex_asset.this : key => asset.uid } | ||
description = "Map of UIDs of our defined assets" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
variable "project" { | ||
type = string | ||
description = "(Required) The project ID to host the resource in" | ||
} | ||
|
||
variable "location" { | ||
type = string | ||
description = "(Required) The location to host the resource in" | ||
} | ||
|
||
variable "assets" { | ||
type = list(object({ | ||
id = string, | ||
lake_id = string, | ||
zone_id = string, | ||
display_name = optional(string), | ||
description = optional(string), | ||
labels = optional(map(string), {}), | ||
discovery_spec = object({ | ||
enabled = bool, | ||
schedule = optional(string), | ||
include_patterns = optional(list(string), []), | ||
exclude_patterns = optional(list(string), []), | ||
csv_options = optional(object({ | ||
delimiter = optional(string, ","), | ||
header_rows = optional(number, 0) | ||
disable_type_inference = optional(bool, false), | ||
encoding = optional(string, "UTF-8") | ||
})) | ||
json_options = optional(object({ | ||
disable_type_inference = optional(bool, false), | ||
encoding = optional(string, "UTF-8") | ||
})), | ||
}), | ||
resource_spec = object({ | ||
name = string, | ||
type = string | ||
}) | ||
})) | ||
default = [] | ||
description = "(Optional) A list of asset objects" | ||
|
||
validation { | ||
condition = alltrue([for asset in var.assets : contains(["STORAGE_BUCKET", "BIGQUERY_DATASET"], asset.resource_spec["type"])]) | ||
error_message = "Supported resource spec types are 'STORAGE_BUCKET' or 'BIGQUERY_DATASET'" | ||
} | ||
} | ||
|
||
variable "lake_self_links" { | ||
type = map(any) | ||
default = {} | ||
description = "(Optional) A map of lake self_links" | ||
} | ||
|
||
variable "zone_self_links" { | ||
type = map(any) | ||
default = {} | ||
description = "(Optional) A map of zone self_links" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 1.3.0, < 2.0.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 4.32.0, < 5.0.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.