diff --git a/internal/services/monitor/monitor_diagnostic_setting_resource_test.go b/internal/services/monitor/monitor_diagnostic_setting_resource_test.go index 42fee46baa6bc..4f3116dcc5ac8 100644 --- a/internal/services/monitor/monitor_diagnostic_setting_resource_test.go +++ b/internal/services/monitor/monitor_diagnostic_setting_resource_test.go @@ -664,10 +664,14 @@ provider "azurerm" { data "azurerm_client_config" "current" { } - data "azurerm_subscription" "current" { } +resource "azurerm_role_assignment" "example" { + scope = data.azurerm_subscription.current.id + role_definition_name = "Monitoring Contributor" + principal_id = data.azurerm_client_config.current.object_id +} resource "azurerm_resource_group" "test" { name = "acctestRG-%[1]d" @@ -682,7 +686,6 @@ resource "azurerm_storage_account" "test" { account_tier = "Standard" } - resource "azurerm_monitor_diagnostic_setting" "test" { name = "acctest-DS-%[1]d" target_resource_id = data.azurerm_subscription.current.id @@ -719,6 +722,8 @@ resource "azurerm_monitor_diagnostic_setting" "test" { enabled_log { category = "ServiceHealth" } + + depends_on = [azurerm_role_assignment.example] } `, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(17)) }