Reputation: 21
I am creating alerts in Azure by using terraform and getting below error
resource "azurerm_monitor_metric_alert" "alertrule"{
for_each = var.triggermap
name = each.key
resource_group_name = var.resource_group_name
scopes = [data.azurerm_function_app.funcapp.id]
description = each.value
dynamic "dynamic_criteria" {
for_each = local.metric_name
content {
metric_namespace = "Microsoft.Web/sites"
metric_name = dynamic_criteria.value
aggregation = "Total"
operator = "GreaterThan"
alert_sensitivity = "Medium"
ignore_data_before = timestamp()
dimension {
name = "Instance"
operator = "Include"
values = ["*"]
}
action {
action_group_id = azurerm_monitor_action_group.ag.id
}
}
}
}
I am getting below error, I am trying to create multiple alerts in azure by creating multiple dynamic criteria but when I am adding dynamic block it is giving me below issue, Above is my main.tf and in locals I am using simple map and list. please help
│ Error: Too many dynamic_criteria blocks
│
│ on ../module/alert.tf line 58, in resource "azurerm_monitor_metric_alert" "alertrule":
│ 58: content {
│
│ No more than 1 "dynamic_criteria" blocks are allowed
╵
╷
│ Error: Unsupported block type
│
│ on ../module/alert.tf line 73, in resource "azurerm_monitor_metric_alert" "alertrule":
│ 73: action {
│
│ Blocks of type "action" are not expected here.
╵
╷
│ Error: Unsupported block type
│
│ on ../module/alert.tf line 73, in resource "azurerm_monitor_metric_alert" "alertrule":
│ 73: action {
│
│ Blocks of type "action" are not expected here.
Upvotes: 0
Views: 1980
Reputation: 238957
You have defined action
in dynamic_criteria
which is not supported, it should be outside of it. Also you can have only one dynamic_criteria
, not multiple ones as you are trying to do. Please check docs:
One of either criteria, dynamic_criteria or application_insights_web_test_location_availability_criteria must be specified.
Upvotes: 2