Skip to content

Commit

Permalink
resource_group: use data source for null location
Browse files Browse the repository at this point in the history
  • Loading branch information
DeviaVir committed Nov 11, 2024
1 parent d23b0c2 commit 83c5882
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion log_analytics.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 83c5882

Please sign in to comment.