diff --git a/internal/services/monitor/monitor_diagnostic_setting_resource.go b/internal/services/monitor/monitor_diagnostic_setting_resource.go index ce1e898a65af..0f41b26737f8 100644 --- a/internal/services/monitor/monitor_diagnostic_setting_resource.go +++ b/internal/services/monitor/monitor_diagnostic_setting_resource.go @@ -279,11 +279,7 @@ func resourceMonitorDiagnosticSettingCreateUpdate(d *pluginsdk.ResourceData, met } if v := d.Get("log_analytics_destination_type").(string); v != "" { - if workspaceId != "" { - parameters.Properties.LogAnalyticsDestinationType = &v - } else { - return fmt.Errorf("`log_analytics_workspace_id` must be set for `log_analytics_destination_type` to be used") - } + parameters.Properties.LogAnalyticsDestinationType = &v } if !valid { diff --git a/internal/services/monitor/monitor_diagnostic_setting_resource_test.go b/internal/services/monitor/monitor_diagnostic_setting_resource_test.go index 8885effd8c33..2e7f4814a64c 100644 --- a/internal/services/monitor/monitor_diagnostic_setting_resource_test.go +++ b/internal/services/monitor/monitor_diagnostic_setting_resource_test.go @@ -220,6 +220,7 @@ resource "azurerm_monitor_diagnostic_setting" "test" { target_resource_id = azurerm_key_vault.test.id eventhub_authorization_rule_id = azurerm_eventhub_namespace_authorization_rule.test.id eventhub_name = azurerm_eventhub.test.name + log_analytics_destination_type = "AzureDiagnostics" log { category = "AuditEvent" @@ -304,6 +305,7 @@ resource "azurerm_monitor_diagnostic_setting" "test" { target_resource_id = azurerm_key_vault.test.id eventhub_authorization_rule_id = azurerm_eventhub_namespace_authorization_rule.test.id eventhub_name = azurerm_eventhub.test.name + log_analytics_destination_type = "AzureDiagnostics" log { category_group = "Audit" @@ -396,9 +398,10 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_monitor_diagnostic_setting" "test" { - name = "acctest-DS-%[1]d" - target_resource_id = azurerm_key_vault.test.id - log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id + name = "acctest-DS-%[1]d" + target_resource_id = azurerm_key_vault.test.id + log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id + log_analytics_destination_type = "AzureDiagnostics" log { category = "AuditEvent" @@ -594,9 +597,10 @@ resource "azurerm_elastic_cloud_elasticsearch" "test" { } resource "azurerm_monitor_diagnostic_setting" "test" { - name = "acctest-DS-%[1]d" - target_resource_id = azurerm_key_vault.test.id - partner_solution_id = azurerm_elastic_cloud_elasticsearch.test.id + name = "acctest-DS-%[1]d" + target_resource_id = azurerm_key_vault.test.id + partner_solution_id = azurerm_elastic_cloud_elasticsearch.test.id + log_analytics_destination_type = "AzureDiagnostics" log { category = "AuditEvent" @@ -659,9 +663,10 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_monitor_diagnostic_setting" "test" { - name = "acctest-DS-%[1]d" - target_resource_id = azurerm_key_vault.test.id - storage_account_id = azurerm_storage_account.test.id + name = "acctest-DS-%[1]d" + target_resource_id = azurerm_key_vault.test.id + storage_account_id = azurerm_storage_account.test.id + log_analytics_destination_type = "AzureDiagnostics" log { category = "AuditEvent" @@ -722,9 +727,10 @@ resource "azurerm_storage_account" "test" { resource "azurerm_monitor_diagnostic_setting" "test" { - name = "acctest-DS-%[1]d" - target_resource_id = data.azurerm_subscription.current.id - storage_account_id = azurerm_storage_account.test.id + name = "acctest-DS-%[1]d" + target_resource_id = data.azurerm_subscription.current.id + storage_account_id = azurerm_storage_account.test.id + log_analytics_destination_type = "AzureDiagnostics" log { category = "Administrative"