1
votes

I just found out, if we create azure service health alert with terraform, with below code

resource "azurerm_monitor_activity_log_alert" "servicehealth" {
  name                = "${var.client_initial}-MCS Maintain Service Health"
  description         = "${var.client_initial}-MCS Maintain Service Health Alerts"
  resource_group_name = var.resource_group_name
  scopes              = [var.scopes]
  criteria {
    category = "ServiceHealth"
  }
  tags = var.tags
  action {
    action_group_id = var.action_group_id
  }
}

when I do terraform apply, it applies fine, but when I check on portal, no region is selected. You can't do the same via portal, if you do via portal, you have to select region or select all regions.

so if deploy via terraform and no region is selected, does that mean it applies to all regions?

i see on github, more granular control on this is still an open issue https://github.com/terraform-providers/terraform-provider-azurerm/issues/2996

2
Any more updates on this question? Does it solve your problem? If it solves your problem please accept it.Charles Xu

2 Answers

2
votes

The region will be determined based on

resource_group_name = var.resource_group_name

where resource_group_name requires an instance of azurerm_resource_group:

resource "azurerm_resource_group" "example" {
  name     = "example"
  location = "West Europe"
}

and

location - (Required) The Azure Region where the Resource Group should exist. Changing this forces a new Resource Group to be created.

0
votes

According to my knowledge, the location of the activity log alert is always Global. The activity log alert can be created at three levels: Resource level, Resource Group level, and Subscription level. Both resource group and subscription can contain multiple regions' resources. And you also cannot set the location when creating it. Not sure, but it seems the activity log alert does not have a special region except the Global.