diff --git a/log_analytics.tf b/log_analytics.tf index 1d3a2993..4905a15e 100644 --- a/log_analytics.tf +++ b/log_analytics.tf @@ -1,7 +1,7 @@ resource "azurerm_log_analytics_workspace" "main" { count = local.create_analytics_workspace ? 1 : 0 - location = coalesce(var.location, data.azurerm_resource_group.main.location) + location = (var.location == null ? data.azurerm_resource_group.main[0].location : var.location) name = coalesce(var.cluster_log_analytics_workspace_name, trim("${var.prefix}-workspace", "-")) resource_group_name = coalesce(var.log_analytics_workspace_resource_group_name, var.resource_group_name) allow_resource_only_permissions = var.log_analytics_workspace_allow_resource_only_permissions diff --git a/main.tf b/main.tf index 499a8b30..bc7cda2c 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,6 @@ data "azurerm_resource_group" "main" { - name = var.resource_group_name + name = var.resource_group_name + count = var.location == null ? 1 : 0 } moved { @@ -15,9 +16,9 @@ resource "tls_private_key" "ssh" { } resource "azurerm_kubernetes_cluster" "main" { - location = coalesce(var.location, data.azurerm_resource_group.main.location) + location = (var.location == null ? data.azurerm_resource_group.main[0].location : var.location) name = "${local.cluster_name}${var.cluster_name_random_suffix ? substr(md5(uuid()), 0, 4) : ""}" - resource_group_name = data.azurerm_resource_group.main.name + resource_group_name = var.resource_group_name automatic_channel_upgrade = var.automatic_channel_upgrade azure_policy_enabled = var.azure_policy_enabled cost_analysis_enabled = var.cost_analysis_enabled