Skip to content

Commit 3179f7b

Browse files
committed
module update
1 parent 01be2c8 commit 3179f7b

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

main.tf

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ resource "random_string" "str" {
4444
}
4545

4646
resource "azurerm_storage_account" "storeacc" {
47-
count = var.enable_sql_server_extended_auditing_policy || var.enable_database_extended_auditing_policy || var.enable_vulnerability_assessment || var.enable_audit_log_monitoring == true ? 1 : 0
47+
count = var.enable_sql_server_extended_auditing_policy || var.enable_database_extended_auditing_policy || var.enable_vulnerability_assessment || var.enable_log_monitoring == true ? 1 : 0
4848
name = var.storage_account_name == null ? "stsqlauditlogs${element(concat(random_string.str.*.result, [""]), 0)}" : substr(var.storage_account_name, 0, 24)
4949
resource_group_name = local.resource_group_name
5050
location = local.location
@@ -103,7 +103,7 @@ resource "azurerm_mssql_server_extended_auditing_policy" "primary" {
103103
storage_account_access_key = azurerm_storage_account.storeacc.0.primary_access_key
104104
storage_account_access_key_is_secondary = false
105105
retention_in_days = var.log_retention_days
106-
log_monitoring_enabled = var.enable_audit_log_monitoring == true && var.log_analytics_workspace_name != null ? true : false
106+
log_monitoring_enabled = var.enable_log_monitoring == true && var.log_analytics_workspace_name != null ? true : false
107107
}
108108

109109
resource "azurerm_sql_server" "secondary" {
@@ -131,7 +131,7 @@ resource "azurerm_mssql_server_extended_auditing_policy" "secondary" {
131131
storage_account_access_key = azurerm_storage_account.storeacc.0.primary_access_key
132132
storage_account_access_key_is_secondary = false
133133
retention_in_days = var.log_retention_days
134-
log_monitoring_enabled = var.enable_audit_log_monitoring == true && var.log_analytics_workspace_name != null ? true : null
134+
log_monitoring_enabled = var.enable_log_monitoring == true && var.log_analytics_workspace_name != null ? true : null
135135
}
136136

137137

@@ -167,7 +167,7 @@ resource "azurerm_mssql_database_extended_auditing_policy" "primary" {
167167
storage_account_access_key = azurerm_storage_account.storeacc.0.primary_access_key
168168
storage_account_access_key_is_secondary = false
169169
retention_in_days = var.log_retention_days
170-
log_monitoring_enabled = var.enable_audit_log_monitoring == true && var.log_analytics_workspace_name != null ? true : null
170+
log_monitoring_enabled = var.enable_log_monitoring == true && var.log_analytics_workspace_name != null ? true : null
171171
}
172172

173173
#-----------------------------------------------------------------------------------------------
@@ -414,18 +414,20 @@ resource "azurerm_private_dns_a_record" "arecord2" {
414414
# azurerm monitoring diagnostics - Default is "false"
415415
#------------------------------------------------------------------
416416
resource "azurerm_monitor_diagnostic_setting" "extaudit" {
417-
count = var.enable_audit_log_monitoring == true && var.log_analytics_workspace_name != null ? 1 : 0
417+
count = var.enable_log_monitoring == true && var.log_analytics_workspace_name != null ? 1 : 0
418418
name = lower("extaudit-${var.database_name}-diag")
419419
target_resource_id = azurerm_sql_database.db.id
420420
log_analytics_workspace_id = data.azurerm_log_analytics_workspace.logws.0.id
421421
storage_account_id = azurerm_storage_account.storeacc.0.id
422422

423-
log {
424-
category = "SQLSecurityAuditEvents"
425-
enabled = true
426-
427-
retention_policy {
428-
enabled = false
423+
dynamic "log" {
424+
for_each = var.extaudit_diag_logs
425+
content {
426+
category = log.value
427+
enabled = true
428+
retention_policy {
429+
enabled = false
430+
}
429431
}
430432
}
431433

@@ -440,4 +442,4 @@ resource "azurerm_monitor_diagnostic_setting" "extaudit" {
440442
lifecycle {
441443
ignore_changes = [log, metric]
442444
}
443-
}
445+
}

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ variable "firewall_rules" {
154154
default = []
155155
}
156156

157-
variable "enable_audit_log_monitoring" {
157+
variable "enable_log_monitoring" {
158158
description = "Enable audit events to Azure Monitor?"
159159
default = false
160160
}

0 commit comments

Comments
 (0)