Skip to content

Commit c08c29c

Browse files
committed
add var.create_monitor_data_collection_rule so users could skip creation of dcr resources in this module
1 parent 3252c5d commit c08c29c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

log_analytics.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ locals {
6969
}
7070

7171
resource "azurerm_monitor_data_collection_rule" "dcr" {
72-
count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0
72+
count = local.create_analytics_workspace && var.oms_agent_enabled && var.create_monitor_data_collection_rule ? 1 : 0
7373

7474
location = local.dcr_location
7575
name = "MSCI-${local.dcr_location}-${azurerm_kubernetes_cluster.main.name}"
@@ -115,7 +115,7 @@ resource "azurerm_monitor_data_collection_rule" "dcr" {
115115
}
116116

117117
resource "azurerm_monitor_data_collection_rule_association" "dcra" {
118-
count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0
118+
count = local.create_analytics_workspace && var.oms_agent_enabled && var.create_monitor_data_collection_rule ? 1 : 0
119119

120120
target_resource_id = azurerm_kubernetes_cluster.main.id
121121
data_collection_rule_id = azurerm_monitor_data_collection_rule.dcr[0].id

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,13 @@ resource "time_sleep" "interval_before_cluster_update" {
693693
}
694694

695695
resource "azapi_update_resource" "aks_cluster_post_create" {
696-
type = "Microsoft.ContainerService/managedClusters@2024-02-01"
696+
resource_id = azurerm_kubernetes_cluster.main.id
697+
type = "Microsoft.ContainerService/managedClusters@2024-02-01"
697698
body = {
698699
properties = {
699700
kubernetesVersion = var.kubernetes_version
700701
}
701702
}
702-
resource_id = azurerm_kubernetes_cluster.main.id
703703

704704
depends_on = [
705705
time_sleep.interval_before_cluster_update,
@@ -722,15 +722,15 @@ resource "null_resource" "http_proxy_config_no_proxy_keeper" {
722722
resource "azapi_update_resource" "aks_cluster_http_proxy_config_no_proxy" {
723723
count = can(var.http_proxy_config.no_proxy[0]) ? 1 : 0
724724

725-
type = "Microsoft.ContainerService/managedClusters@2024-02-01"
725+
resource_id = azurerm_kubernetes_cluster.main.id
726+
type = "Microsoft.ContainerService/managedClusters@2024-02-01"
726727
body = {
727728
properties = {
728729
httpProxyConfig = {
729730
noProxy = var.http_proxy_config.no_proxy
730731
}
731732
}
732733
}
733-
resource_id = azurerm_kubernetes_cluster.main.id
734734

735735
depends_on = [azapi_update_resource.aks_cluster_post_create]
736736

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,13 @@ variable "cost_analysis_enabled" {
436436
description = "(Optional) Enable Cost Analysis."
437437
}
438438

439+
variable "create_monitor_data_collection_rule" {
440+
type = bool
441+
default = true
442+
description = "Create monitor data collection rule resource for the AKS cluster. Defaults to `true`."
443+
nullable = false
444+
}
445+
439446
variable "create_role_assignment_network_contributor" {
440447
type = bool
441448
default = false

0 commit comments

Comments
 (0)