Terraform 中的动态块 - 不允许超过 1 "dynamic_criteria" 个块
Dynamic Block in Terraform - No more than 1 "dynamic_criteria" blocks are allowed
我正在使用 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.
您在 dynamic_criteria
中定义了 action
不受支持,它应该在它之外。您也可以 只有一个 dynamic_criteria
,而不是您尝试做的多个。请检查 docs:
One of either criteria, dynamic_criteria or application_insights_web_test_location_availability_criteria must be specified.
我正在使用 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.
您在 dynamic_criteria
中定义了 action
不受支持,它应该在它之外。您也可以 只有一个 dynamic_criteria
,而不是您尝试做的多个。请检查 docs:
One of either criteria, dynamic_criteria or application_insights_web_test_location_availability_criteria must be specified.