hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Activity Log Alert (Resource Health) Supported API Version Unavailable (in US Government Env) #14481

Open HS-Lim opened 2 years ago

HS-Lim commented 2 years ago

Community Note

Terraform (and AzureRM Provider) Version

Terraform v1.0.11 on windows_amd64

azurerm = {
      version = "2.88.1"
      source  = "hashicorp/azurerm"
    }

Affected Resource(s)

Terraform Configuration Files

resource "azurerm_monitor_activity_log_alert" "resource_health" {
  name                = "Resource Health Alert"
  resource_group_name = var.resource_group_name
  scopes              = [var.subscription_id]
  description         = "This alert monitors resource health on a resource to resource granularity."
  criteria {
    category = "ResourceHealth"
  }
  action {
    action_group_id    = azurerm_monitor_action_group.email.id
    webhook_properties = {}
  }
}

Expected Behaviour

An activity log alert of category Resource Health should be created.

Actual Behaviour

Error: creating or updating Monitor Activity Log Alert: (Name "Resource Health Alert" / Resource Group "**-**-**"): insights.ActivityLogAlertsClient#CreateOrUpdate: Failure responding to reque
st: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="NoRegisteredProviderFound" Message="No registered resource provider found for location 'global' and API versio
n '2020-10-01' for type 'activityLogAlerts'. The supported api-versions are '2017-03-01-preview, 2017-04-01'. The supported locations are 'global'."
│   on .terraform\modules\azure_monitoring_and_alerts\resources.alerts.tf line 76, in resource "azurerm_monitor_activity_log_alert" "resource_health":
│   76: resource "azurerm_monitor_activity_log_alert" "resource_health" {

Steps to Reproduce

  1. Set `environment = "usgovernment" under provider "azurerm"
  2. Attempt to create resource as above.
  3. terraform apply

Important Factoids

Issue occurs when utilizing Azure Government environment, location US Gov Virginia. Issue is not reproduced when using public environment, presumably because the api version 2020-10-01 is available.

ljluestc commented 1 year ago

provider "azurerm" { features {} environment = "usgovernment" # Set the Azure Government environment version = "2.88.1" }

resource "azurerm_monitor_activity_log_alert" "resource_health" { name = "Resource Health Alert" resource_group_name = var.resource_group_name scopes = [var.subscription_id] description = "This alert monitors resource health on a resource to resource granularity." criteria { category = "ResourceHealth" } action { action_group_id = azurerm_monitor_action_group.email.id webhook_properties = {} }

Specify the compatible API version for Azure Government

depends_on = [provider.azurerm] }