Open fjalcarazp opened 5 months ago
By the way, If I enable all logs in the Azure SQL Server the Azure SQL Auditing is also enabled but the event hub is not configured properly as well.
resource "azurerm_mssql_server_extended_auditing_policy" "mssqlserver_audit_policy" {
server_id = azurerm_mssql_server.mssqlserver.id
log_monitoring_enabled = true
}
resource "azurerm_monitor_diagnostic_setting" "mssql_diagnotic_setting" {
# If the first deployment fails, run it again.
name = "datadog"
target_resource_id = "${azurerm_mssql_server.mssqlserver.id}/databases/master"
eventhub_authorization_rule_id = data.azurerm_eventhub_namespace_authorization_rule.evhns_datadog_authorization_rule.id
eventhub_name = data.azurerm_eventhub.evh_datadog.name
enabled_log {
# category = "SQLSecurityAuditEvents"
category_group = "AllLogs"
}
metric {
category = "AllMetrics"
}
# lifecycle {
# ignore_changes = [enabled_log, metric]
# }
}
I've got the same issue when pointing to a Log Analytics Workspace
resource "azurerm_mssql_server_extended_auditing_policy" "this" {
server_id = azurerm_mssql_server.this.id
log_monitoring_enabled = true
}
resource "azurerm_mssql_server_microsoft_support_auditing_policy" "this" {
server_id = azurerm_mssql_server.this.id
log_monitoring_enabled = true
}
resource "azurerm_monitor_diagnostic_setting" "this_mssql" {
lifecycle {
ignore_changes = [
log_analytics_workspace_id,
log,
metric
]
}
name = join("", ["sqldiag", var.sqlep_azurerm_app_name, var.enviroment, var.abrloc])
target_resource_id = "${azurerm_mssql_server.this.id}/databases/master"
log_analytics_workspace_id = var.workspace_id
enabled_log {
category_group = "AllLogs"
}
metric {
category = "AllMetrics"
}
}
In my company currently Cybersecurity department are requesting for this on any SQLdatabase creation that will having sensitive data.
Is there an existing issue for this?
Community Note
I need to enable Azure SQL Auditing on both the Azure SQL Server and the Azure SQL Database, and send the logs to an Event Hub. Additionally, I want to configure the diagnostic settings to send all logs and metrics to the Event Hub.
When I apply this Terraform code, the SQL audit logs are enabled, but the Event Hub is not configured in the Azure portal:
If I apply this Terraform code, the SQL audit logs are enabled properly, but the diagnostic settings do not have all logs enabled:
Terraform Version
1.9.0
AzureRM Provider Version
3.107.0
Affected Resource(s)/Data Source(s)
azurerm_monitor_diagnostic_setting; azurerm_mssql_database;
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Actual Behaviour
It is not possible to enable all logs and Azure SQL Auditing logs simultaneously and send them to an Event Hub.
Steps to Reproduce
terraform apply
Important Factoids
No response
References
No response