From c12ff44ebf57e7141c6bb3fe21610052a29d985b Mon Sep 17 00:00:00 2001 From: Assaf Giladi Date: Mon, 2 Dec 2024 12:20:33 -0800 Subject: [PATCH] fix: fetch application insights info only when required --- functions.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions.tf b/functions.tf index 9326f481..61bfb791 100644 --- a/functions.tf +++ b/functions.tf @@ -215,13 +215,14 @@ data "azurerm_application_insights" "application_insights" { } data "azurerm_resource_group" "application_insights_rg" { - name = local.application_insights_rg_name + count = var.application_insights_name == "" && var.enable_application_insights ? 1 : 0 + name = local.application_insights_rg_name } resource "azurerm_application_insights" "application_insights" { count = var.application_insights_name == "" && var.enable_application_insights ? 1 : 0 name = "${var.prefix}-${var.cluster_name}-application-insights" - location = data.azurerm_resource_group.application_insights_rg.location + location = data.azurerm_resource_group.application_insights_rg[0].location resource_group_name = local.application_insights_rg_name workspace_id = local.log_analytics_workspace_id application_type = "web"