diff --git a/README.md b/README.md
index 9e6c0d55..3f2b2abd 100644
--- a/README.md
+++ b/README.md
@@ -429,6 +429,7 @@ proxy_url = VALUE
| [allow\_ssh\_cidrs](#input\_allow\_ssh\_cidrs) | Allow port 22, if not provided, i.e leaving the default empty list, the rule will not be included in the SG | `list(string)` | `[]` | no |
| [allow\_weka\_api\_cidrs](#input\_allow\_weka\_api\_cidrs) | Allow connection to port 14000 on weka backends from specified CIDRs, by default no CIDRs are allowed. All ports (including 14000) are allowed within Vnet | `list(string)` | `[]` | no |
| [application\_insights\_name](#input\_application\_insights\_name) | The Application Insights name. | `string` | `""` | no |
+| [application\_insights\_rg\_name](#input\_application\_insights\_rg\_name) | The Application Insights resource group name. | `string` | `""` | no |
| [apt\_repo\_server](#input\_apt\_repo\_server) | The URL of the apt private repository. | `string` | `""` | no |
| [assign\_public\_ip](#input\_assign\_public\_ip) | Determines whether to assign public IP to all instances deployed by TF module. Includes backends, clients and protocol gateways. | `string` | `"auto"` | no |
| [client\_arch](#input\_client\_arch) | Use arch for ami id, value can be arm64/x86\_64. | `string` | `null` | no |
diff --git a/functions.tf b/functions.tf
index 90bfd570..bde4ccbe 100644
--- a/functions.tf
+++ b/functions.tf
@@ -17,9 +17,10 @@ locals {
install_weka_url = var.install_weka_url != "" ? var.install_weka_url : "https://$TOKEN@get.weka.io/dist/v1/install/${var.weka_version}/${var.weka_version}"
supported_regions = split("\n", replace(chomp(file("${path.module}/supported_regions/${var.function_app_dist}.txt")), "\r", ""))
# log analytics for function app
- log_analytics_workspace_id = var.enable_application_insights ? var.log_analytics_workspace_id == "" ? azurerm_log_analytics_workspace.la_workspace[0].id : var.log_analytics_workspace_id : ""
- application_insights_id = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].id : data.azurerm_application_insights.application_insights[0].id : ""
- insights_instrumenation_key = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].instrumentation_key : data.azurerm_application_insights.application_insights[0].instrumentation_key : ""
+ log_analytics_workspace_id = var.enable_application_insights ? var.log_analytics_workspace_id == "" ? azurerm_log_analytics_workspace.la_workspace[0].id : var.log_analytics_workspace_id : ""
+ application_insights_id = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].id : data.azurerm_application_insights.application_insights[0].id : ""
+ application_insights_rg_name = var.application_insights_rg_name == "" ? var.rg_name : var.application_insights_rg_name
+ insights_instrumenation_key = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].instrumentation_key : data.azurerm_application_insights.application_insights[0].instrumentation_key : ""
# nfs autoscaling
nfs_deployment_container_name = var.nfs_deployment_container_name == "" ? "${local.alphanumeric_prefix_name}${local.alphanumeric_cluster_name}-protocol-deployment" : var.nfs_deployment_container_name
@@ -199,7 +200,7 @@ resource "azurerm_log_analytics_workspace" "la_workspace" {
count = var.log_analytics_workspace_id == "" && var.enable_application_insights ? 1 : 0
name = "${local.alphanumeric_prefix_name}-${local.alphanumeric_cluster_name}-workspace"
location = data.azurerm_resource_group.rg.location
- resource_group_name = data.azurerm_resource_group.rg.name
+ resource_group_name = var.rg_name
sku = "PerGB2018"
retention_in_days = 30
lifecycle {
@@ -210,14 +211,14 @@ resource "azurerm_log_analytics_workspace" "la_workspace" {
data "azurerm_application_insights" "application_insights" {
count = var.application_insights_name != "" && var.enable_application_insights ? 1 : 0
name = var.application_insights_name
- resource_group_name = data.azurerm_resource_group.rg.name
+ resource_group_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.rg.location
- resource_group_name = data.azurerm_resource_group.rg.name
+ resource_group_name = local.application_insights_rg_name
workspace_id = local.log_analytics_workspace_id
application_type = "web"
lifecycle {
diff --git a/variables.tf b/variables.tf
index e2bae2b3..5dc8558b 100644
--- a/variables.tf
+++ b/variables.tf
@@ -454,6 +454,12 @@ variable "application_insights_name" {
default = ""
}
+variable "application_insights_rg_name" {
+ type = string
+ description = "The Application Insights resource group name."
+ default = ""
+}
+
variable "enable_application_insights" {
type = bool
default = true