-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Module databricks access connector (#1933)
* adding dac module * Update databricks_access_connectors.tf * Update main.tf * Update configuration.tfvars
- Loading branch information
1 parent
721aa7c
commit 61f82e1
Showing
12 changed files
with
134 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module "databricks_access_connectors" { | ||
source = "./modules/analytics/databricks_access_connector" | ||
for_each = local.database.databricks_access_connectors | ||
|
||
client_config = local.client_config | ||
global_settings = local.global_settings | ||
name = each.value.name | ||
settings = each.value | ||
resource_groups = local.combined_objects_resource_groups | ||
base_tags = local.global_settings.inherit_tags | ||
remote_objects = { | ||
managed_identities = local.combined_objects_managed_identities | ||
} | ||
} | ||
|
||
output "databricks_access_connectors" { | ||
value = module.databricks_access_connectors | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/databricks_access_connectors/100-databricks_access_connectors/configuration.tfvars
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,34 @@ | ||
global_settings = { | ||
default_region = "region1" | ||
regions = { | ||
region1 = "australiaeast" | ||
} | ||
} | ||
|
||
resource_groups = { | ||
dac_test = { | ||
name = "rg-databricks-access-connectors" | ||
} | ||
} | ||
|
||
databricks_access_connectors = { | ||
dac_1 = { | ||
name = "example-name" | ||
resource_group_key = "dac_test" | ||
identity = { | ||
type = "UserAssigned" #SystemAssigned | ||
managed_identity_keys = ["dac_test"] | ||
} | ||
tags = { | ||
test = "test" | ||
test1 = "test1" | ||
} | ||
} | ||
} | ||
|
||
managed_identities = { | ||
dac_test = { | ||
name = "mi-dac-test" | ||
resource_group_key = "dac_test" | ||
} | ||
} |
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
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,18 @@ | ||
locals { | ||
tags = var.base_tags ? merge( | ||
var.global_settings.tags, | ||
try(var.resource_groups.tags, null), | ||
try(var.settings.tags, null) | ||
) : try(var.settings.tags, null) | ||
|
||
|
||
resource_group = var.resource_groups[try(var.settings.lz_key, var.settings.resource_group.lz_key, var.client_config.landingzone_key)][try(var.settings.resource_group.key, var.settings.resource_group_key)] | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
azurecaf = { | ||
source = "aztfmod/azurecaf" | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
modules/analytics/databricks_access_connector/managed_identities.tf
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,17 @@ | ||
locals { | ||
managed_local_identities = flatten([ | ||
for managed_identity_key in try(var.settings.identity.managed_identity_keys, []) : [ | ||
var.remote_objects.managed_identities[var.client_config.landingzone_key][managed_identity_key].id | ||
] | ||
]) | ||
|
||
managed_remote_identities = flatten([ | ||
for lz_key, value in try(var.settings.identity.remote, []) : [ | ||
for managed_identity_key in value.managed_identity_keys : [ | ||
var.remote_objects.managed_identities[lz_key][managed_identity_key].id | ||
] | ||
] | ||
]) | ||
|
||
managed_identities = concat(local.managed_local_identities, local.managed_remote_identities) | ||
} |
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,15 @@ | ||
resource "azurerm_databricks_access_connector" "databricks_access_connector" { | ||
name = var.name | ||
resource_group_name = local.resource_group.name | ||
location = lookup(var.settings, "region", null) == null ? local.resource_group.location : var.global_settings.regions[var.settings.region] | ||
tags = local.tags | ||
|
||
dynamic "identity" { | ||
for_each = can(var.settings.identity) ? [var.settings.identity] : [] | ||
content { | ||
type = identity.value.type | ||
identity_ids = concat(local.managed_identities, try(identity.value.identity_ids, [])) | ||
} | ||
} | ||
|
||
} |
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,4 @@ | ||
output "id" { | ||
description = "The ID of the Manages a Databricks Access Connector." | ||
value = azurerm_databricks_access_connector.databricks_access_connector.id | ||
} |
21 changes: 21 additions & 0 deletions
21
modules/analytics/databricks_access_connector/variables.tf
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,21 @@ | ||
variable "name" { | ||
default = null | ||
} | ||
variable "settings" {} | ||
|
||
variable "global_settings" { | ||
description = "Global settings object (see module README.md)" | ||
} | ||
|
||
variable "client_config" { | ||
description = "Client configuration object (see module README.md)." | ||
} | ||
|
||
variable "resource_groups" { | ||
default = {} | ||
} | ||
variable "base_tags" { | ||
description = "Base tags for the resource to be inherited from the resource group." | ||
type = bool | ||
} | ||
variable "remote_objects" {} |