为主题创建事件网格订阅时获取 'ID contained more segments than required'
When creating Event Grid Subscription for topic getting 'ID contained more segments than required'
已创建用于部署事件网格订阅的代码(订阅现有主题,使用现有存储帐户和资源组)。
locals {
environment = terraform.workspace
}
# existing data
data "azurerm_resource_group" "rg" {
name = "rg-1"
}
data "azurerm_storage_account" "sa" {
name = "sa1${local.environment}"
resource_group_name = data.azurerm_resource_group.rg.name
}
data "azurerm_eventgrid_topic" "topic" {
name = "topic-${local.environment}"
resource_group_name = data.azurerm_resource_group.rg.name
}
# Resources
resource "azurerm_storage_queue" "queue" {
name = "sq-${local.environment}"
storage_account_name = data.azurerm_storage_account.sa.name
}
resource "azurerm_eventgrid_event_subscription" "sub" {
name = "sub-${local.environment}"
scope = data.azurerm_eventgrid_topic.topic.id
storage_queue_endpoint {
storage_account_id = data.azurerm_storage_account.sa.id
queue_name = azurerm_storage_queue.queue.name
}
}
订阅将消息推送到存储队列。很简单的情况。 Terraform 计划第一次正确执行。当我 运行 应用它时出错了:
azurerm_storage_queue.queue: Creating...
azurerm_storage_queue.queue: Creation complete after 1s [id=https://sa1dev.queue.core.windows.net/sq-dev]
azurerm_eventgrid_event_subscription.sub: Creating...
azurerm_eventgrid_event_subscription.sub: Still creating... [10s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [20s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [30s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [40s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [50s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [1m0s elapsed]
Error: ID contained more segments than required: "/subscriptions/[SUBSCRIPTION]/resourceGroups/rg-1/providers/Microsoft.EventGrid/topics/topic-dev/providers/Microsoft.EventGrid/eventSubscriptions/sub-dev"
on main.tf line 27, in resource "azurerm_eventgrid_event_subscription" "sub":
27: resource "azurerm_eventgrid_event_subscription" "sub" {
现在我看到应用后效果很好(订阅存在并将消息保存到存储队列)。但是在应用它之后无法 运行 terraform plan,因为上面的错误。
有人知道怎么解决吗?
地形 0.12.25
+ provider.azurerm v.2.10.0
似乎这是一个已知的错误,将在 2.11.0 中修复link
回到 2.6.0 版本解决了这个问题,与更新到 2.11.0(刚刚发布)一样。
已创建用于部署事件网格订阅的代码(订阅现有主题,使用现有存储帐户和资源组)。
locals {
environment = terraform.workspace
}
# existing data
data "azurerm_resource_group" "rg" {
name = "rg-1"
}
data "azurerm_storage_account" "sa" {
name = "sa1${local.environment}"
resource_group_name = data.azurerm_resource_group.rg.name
}
data "azurerm_eventgrid_topic" "topic" {
name = "topic-${local.environment}"
resource_group_name = data.azurerm_resource_group.rg.name
}
# Resources
resource "azurerm_storage_queue" "queue" {
name = "sq-${local.environment}"
storage_account_name = data.azurerm_storage_account.sa.name
}
resource "azurerm_eventgrid_event_subscription" "sub" {
name = "sub-${local.environment}"
scope = data.azurerm_eventgrid_topic.topic.id
storage_queue_endpoint {
storage_account_id = data.azurerm_storage_account.sa.id
queue_name = azurerm_storage_queue.queue.name
}
}
订阅将消息推送到存储队列。很简单的情况。 Terraform 计划第一次正确执行。当我 运行 应用它时出错了:
azurerm_storage_queue.queue: Creating...
azurerm_storage_queue.queue: Creation complete after 1s [id=https://sa1dev.queue.core.windows.net/sq-dev]
azurerm_eventgrid_event_subscription.sub: Creating...
azurerm_eventgrid_event_subscription.sub: Still creating... [10s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [20s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [30s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [40s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [50s elapsed]
azurerm_eventgrid_event_subscription.sub: Still creating... [1m0s elapsed]
Error: ID contained more segments than required: "/subscriptions/[SUBSCRIPTION]/resourceGroups/rg-1/providers/Microsoft.EventGrid/topics/topic-dev/providers/Microsoft.EventGrid/eventSubscriptions/sub-dev"
on main.tf line 27, in resource "azurerm_eventgrid_event_subscription" "sub":
27: resource "azurerm_eventgrid_event_subscription" "sub" {
现在我看到应用后效果很好(订阅存在并将消息保存到存储队列)。但是在应用它之后无法 运行 terraform plan,因为上面的错误。
有人知道怎么解决吗? 地形 0.12.25 + provider.azurerm v.2.10.0
似乎这是一个已知的错误,将在 2.11.0 中修复link
回到 2.6.0 版本解决了这个问题,与更新到 2.11.0(刚刚发布)一样。