Azure 应用功能标志的 Terraform 应用错误 'The number of path segments is not divisible by 2'

Terraform apply error 'The number of path segments is not divisible by 2' for Azure App Feature Flag

Azure 应用功能标志的 Terraform 应用错误 'The number of path segments is not divisible by 2'

为什么我会看到这个错误?很难在任何地方找到任何答案。我正在使用 Terraform v2.93.0 我也尝试了 2.90.0 和 2.56.0,也遇到了同样的问题。我添加的配置很好但是 一旦我尝试配置功能标志,它就会破坏 Terraform 项目并且 我被迫从头开始重建重新初始化。如果我删除配置并再次 运行 plan,Terraform 无法自行恢复。

╷
│ Error: while parsing resource ID: while parsing resource ID:  
| The number of path segments is not divisible by 2 in 
|  "subscriptions/{key}/resourceGroups/my-config-test/providers/Microsoft.AppConfiguration/configurationStores/my-app-configuration/AppConfigurationFeature/.appconfig.featureflag/DEBUG/Label/my-functions-test"
│ 
│ while parsing resource ID: while parsing resource ID: 
| The number of path segments is not divisible by 2 in
│ "subscriptions/{key}/resourceGroups/my-config-test/providers/Microsoft.AppConfiguration/configurationStores/my-app-configuration/AppConfigurationFeature/.appconfig.featureflag/DEBUG/Label/my-functions-test"
╵
╷
│ Error: obtaining auth token for "https://my-app-configuration.azconfig.io": getting authorization token for endpoint https://my-app-configuration.azconfig.io: 
|  obtaining Authorization Token from the Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: The command failed with an unexpected error. Here is the traceback:
│ ERROR: [Errno 2] No such file or directory

为什么 ID 前面的斜杠不见了????

这是破坏它的配置:

resource "azurerm_app_configuration_feature" "my_functions_test_DEBUG" {
  configuration_store_id = azurerm_app_configuration.my_app_configuration.id
  description            = "Debug Flag"
  name                   = "DEBUG"
  label                  = "my-functions-test"
  enabled                = false
}

当它运行良好时,配置上的应用会起作用,看起来像这样:

Plan: 4 to add, 0 to change, 0 to destroy.

Do you want to perform these actions in workspace "my-app-config-test"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

azurerm_resource_group.my_config_rg_test: Creating...
azurerm_resource_group.my_config_rg_test: Creation complete after 0s [id=/subscriptions/{key}/resourceGroups/my-config-test]

好的,我明白了。有一个错误:当创建一个 azurerm_app_configuration_key 资源时,密钥可以像这样 key = "/application/config.EXSTREAM_DOMAIN" 但是当你创建一个 azurerm_app_configuration_feature 时,如果你尝试设置名称,你将 HOSE 你的 terraform 配置字段到 name = .appconfig.featureflag/DEBUG。相反,只需将名称字段设置为 DEBUG。如果你不这样做,你必须完全重置你的地形和 re-initialize 所有资源。不得不学习艰难的方法。错误消息没有帮助,但可以更新以在这方面有所帮助。