【发布时间】:2021-07-28 09:58:36
【问题描述】:
我正在使用 terraform 在 Azure 中创建警报并遇到错误
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
}
}
}
}
我遇到了错误,我试图通过创建多个动态条件在 azure 中创建多个警报,但是当我添加动态块时,它给了我以下问题,上面是我的 main.tf,而在本地我使用的是简单的地图和列表。请帮忙
│ 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.
【问题讨论】:
标签: azure-devops terraform terraform-provider-azure