创建 Azure 配置密钥时出现"路径段数不能被 2 整除"的地形错误



我试图通过Terraform创建Azure应用程序配置服务和密钥,但是当我通过我的管道运行我的Terraform时,我得到运行terraform plan的错误。这是我创建服务和密钥的tf脚本:

resource "azurerm_app_configuration" "appconf" {
name                = var.name
location            = var.location
resource_group_name = var.resource_group_name
tags                = var.tags
sku                 = "standard"
}
resource "azurerm_app_configuration_key" "MainAPI" {
configuration_store_id = azurerm_app_configuration.appconf.id
key                    = "MainAPI"
value                  = var.picking_api_url
type                   = "kv"
label                  = var.environment_name
}
# other keys omitted

这是我看到的错误:Error: while parsing resource ID: while parsing resource ID: the number of path segments is not divisible by 2 in "subscriptions/[SubscriptionId]/resourceGroups/[rgName]/providers/Microsoft.AppConfiguration/configurationStores/[AppConfigServiceName]/AppConfigurationKey/MainAPI/Label"

我得到这个错误,不管我是否显式地包括一个label参数的关键在我的TF脚本。我已经将我的Terraform ARM提供程序版本升级到2.90,以防它是提供程序中的错误,但仍然得到错误。

资源"azurerm_app_configuration_key"依赖于azurerm_role_assignment。您还需要为此定义一个资源,以便为app_configuration分配角色。

下面的代码来自Hashicorp Terraformazurerm_app_configuration_key文档,演示了如何做到这一点:

resource "azurerm_role_assignment" "appconf_dataowner" {
scope                = azurerm_app_configuration.appconf.id
role_definition_name = "App Configuration Data Owner"
principal_id         = data.azurerm_client_config.current.object_id
}
resource "azurerm_app_configuration_key" "test" {
configuration_store_id = azurerm_app_configuration.appconf.id
key                    = "appConfKey1"
label                  = "somelabel"
value                  = "a test"
depends_on = [
azurerm_role_assignment.appconf_dataowner
]
}

最新更新