Skip to content

Commit

Permalink
Merge pull request #106 from PerfectThymeTech/marvinbuss/cleanup
Browse files Browse the repository at this point in the history
Cleanup variables and locals
  • Loading branch information
marvinbuss authored Nov 21, 2024
2 parents 002773f + 1825037 commit c1e147a
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 28 deletions.
1 change: 0 additions & 1 deletion .github/workflows/_terraformEnvironmentTemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ jobs:
ARM_SUBSCRIPTION_ID: ${{ inputs.subscription_id }}
ARM_CLIENT_ID: ${{ secrets.CLIENT_ID }}
ARM_USE_OIDC: true
TF_LOG: DEBUG

steps:
# Setup Node
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,7 @@ Type:
```hcl
object(
{
private_endpoint_subnet = optional(string, "")
databricks_private_subnet = optional(string, "")
databricks_public_subnet = optional(string, "")
private_endpoint_subnet = optional(string, "")
}
)
```
Expand Down
2 changes: 1 addition & 1 deletion databricksaccessconnector.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module "databricks_access_connector" {
for_each = toset(var.locations_databricks)

location = each.value
resource_group_name = azurerm_resource_group.consumption_adb_rg[each.key].name
resource_group_name = azurerm_resource_group.connectivity_adb_rg[each.key].name
tags = var.tags
databricks_access_connector_name = "${local.prefix}-${each.value}-dbac001"
}
2 changes: 1 addition & 1 deletion databricksworkspace.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module "databricks_workspace" {

location = each.value
location_private_endpoint = var.location
resource_group_name = azurerm_resource_group.consumption_adb_rg[each.key].name
resource_group_name = azurerm_resource_group.connectivity_adb_rg[each.key].name
tags = var.tags
databricks_workspace_name = "${local.prefix}-${each.value}-dbw001"
databricks_workspace_access_connector_id = module.databricks_access_connector[each.key].databricks_access_connector_id
Expand Down
6 changes: 2 additions & 4 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
name = try(split("/", var.route_table_id)[8], "")
}
subnet_cidr_ranges = {
private_endpoint_subnet = var.subnet_cidr_ranges.private_endpoint_subnet != "" ? var.subnet_cidr_ranges.private_endpoint_subnet : tostring(cidrsubnet(data.azurerm_virtual_network.virtual_network.address_space[0], 27 - tonumber(reverse(split("/", data.azurerm_virtual_network.virtual_network.address_space[0]))[0]), 0))
databricks_private_subnet = var.subnet_cidr_ranges.databricks_private_subnet != "" ? var.subnet_cidr_ranges.databricks_private_subnet : tostring(cidrsubnet(data.azurerm_virtual_network.virtual_network.address_space[0], 26 - tonumber(reverse(split("/", data.azurerm_virtual_network.virtual_network.address_space[0]))[0]), 1))
databricks_public_subnet = var.subnet_cidr_ranges.databricks_public_subnet != "" ? var.subnet_cidr_ranges.databricks_public_subnet : tostring(cidrsubnet(data.azurerm_virtual_network.virtual_network.address_space[0], 26 - tonumber(reverse(split("/", data.azurerm_virtual_network.virtual_network.address_space[0]))[0]), 2))
private_endpoint_subnet = var.subnet_cidr_ranges.private_endpoint_subnet != "" ? var.subnet_cidr_ranges.private_endpoint_subnet : tostring(cidrsubnet(data.azurerm_virtual_network.virtual_network.address_space[0], 27 - tonumber(reverse(split("/", data.azurerm_virtual_network.virtual_network.address_space[0]))[0]), 0))
}
connectivity_delay_in_seconds = 10
connectivity_delay_in_seconds = 30
databricks_private_subnet_name = "DatabricksPrivateSubnet"
databricks_public_subnet_name = "DatabricksPublicSubnet"

Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ resource "azurerm_resource_group" "governance_rg" {
tags = var.tags
}

resource "azurerm_resource_group" "consumption_adb_rg" {
resource "azurerm_resource_group" "connectivity_adb_rg" {
for_each = toset(var.locations_databricks)

name = "${local.prefix}-consumption-adb-${each.value}-rg"
name = "${local.prefix}-connectivity-adb-${each.value}-rg"
location = var.location
tags = var.tags
}
Expand All @@ -20,8 +20,8 @@ resource "azurerm_resource_group" "container_rg" {
tags = var.tags
}

resource "azurerm_resource_group" "consumption_synapse_rg" {
name = "${local.prefix}-consumption-syn-rg"
resource "azurerm_resource_group" "connectivity_synapse_rg" {
name = "${local.prefix}-connectivity-syn-rg"
location = var.location
tags = var.tags
}
Expand Down
6 changes: 3 additions & 3 deletions network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resource "azurerm_network_security_group" "network_security_group_databricks" {

name = "${local.prefix}-${each.value}-nsg001"
location = each.value
resource_group_name = azurerm_resource_group.consumption_adb_rg[each.key].name
resource_group_name = azurerm_resource_group.connectivity_adb_rg[each.key].name
tags = var.tags

lifecycle {
Expand All @@ -42,7 +42,7 @@ resource "azurerm_route_table" "route_table_databricks" {

name = "${local.prefix}-${each.value}-rt001"
location = each.value
resource_group_name = azurerm_resource_group.consumption_adb_rg[each.key].name
resource_group_name = azurerm_resource_group.connectivity_adb_rg[each.key].name
tags = var.tags

bgp_route_propagation_enabled = false
Expand All @@ -54,7 +54,7 @@ resource "azurerm_virtual_network" "virtual_network_databricks" {

name = "${local.prefix}-${each.value}-vnet001"
location = each.value
resource_group_name = azurerm_resource_group.consumption_adb_rg[each.key].name
resource_group_name = azurerm_resource_group.connectivity_adb_rg[each.key].name
tags = var.tags

address_space = ["10.0.0.0/20"]
Expand Down
2 changes: 1 addition & 1 deletion synapseprivatelinkhub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module "synapse_private_link_hub" {
}

location = var.location
resource_group_name = azurerm_resource_group.consumption_synapse_rg.name
resource_group_name = azurerm_resource_group.connectivity_synapse_rg.name
tags = var.tags
synapse_private_link_hub_name = replace("${local.prefix}-synplh001", "-", "")
diagnostics_configurations = local.diagnostics_configurations
Expand Down
6 changes: 1 addition & 5 deletions tests/e2e/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,14 @@ variable "subnet_cidr_ranges" {
description = "Specifies the cidr ranges of the subnets used for the Data Management Zone. If not specified, the module will automatically define the right subnet cidr ranges. For this to work, the provided vnet must have no subnets."
type = object(
{
private_endpoint_subnet = optional(string, "")
databricks_private_subnet = optional(string, "")
databricks_public_subnet = optional(string, "")
private_endpoint_subnet = optional(string, "")
}
)
sensitive = false
default = {}
validation {
condition = alltrue([
var.subnet_cidr_ranges.private_endpoint_subnet == "" || try(cidrnetmask(var.subnet_cidr_ranges.private_endpoint_subnet), "invalid") != "invalid",
var.subnet_cidr_ranges.databricks_private_subnet == "" || try(cidrnetmask(var.subnet_cidr_ranges.databricks_private_subnet), "invalid") != "invalid",
var.subnet_cidr_ranges.databricks_public_subnet == "" || try(cidrnetmask(var.subnet_cidr_ranges.databricks_public_subnet), "invalid") != "invalid",
])
error_message = "Please specify a valid CIDR range for all subnets."
}
Expand Down
6 changes: 1 addition & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,14 @@ variable "subnet_cidr_ranges" {
description = "Specifies the cidr ranges of the subnets used for the Data Management Zone. If not specified, the module will automatically define the right subnet cidr ranges. For this to work, the provided vnet must have no subnets."
type = object(
{
private_endpoint_subnet = optional(string, "")
databricks_private_subnet = optional(string, "")
databricks_public_subnet = optional(string, "")
private_endpoint_subnet = optional(string, "")
}
)
sensitive = false
default = {}
validation {
condition = alltrue([
var.subnet_cidr_ranges.private_endpoint_subnet == "" || try(cidrnetmask(var.subnet_cidr_ranges.private_endpoint_subnet), "invalid") != "invalid",
var.subnet_cidr_ranges.databricks_private_subnet == "" || try(cidrnetmask(var.subnet_cidr_ranges.databricks_private_subnet), "invalid") != "invalid",
var.subnet_cidr_ranges.databricks_public_subnet == "" || try(cidrnetmask(var.subnet_cidr_ranges.databricks_public_subnet), "invalid") != "invalid",
])
error_message = "Please specify a valid CIDR range for all subnets."
}
Expand Down

0 comments on commit c1e147a

Please sign in to comment.