使用 Terraform azapi 更新密钥保管库时出现错误

问题描述 投票:0回答:1

我正在尝试在 terraform 中上传密钥库秘密值,但出现错误

resource "azapi_update_resource" "keyvault_secret_update_function_app_id" {
type                   = "Microsoft.KeyVault/vaults/secrets@2022-07-01"
resource_id            = "/subscriptions/myguid/resourceGroups/resource-group-name/providers/Microsoft.KeyVault/vaults/ali-test-remotely-kv-dev/secrets/remotely-managed"
response_export_values = ["*"]
body = jsonencode({
properties = {
  value = "test value"
}
})
}

我收到以下错误

Error: Invalid Type
│
│   with azapi_update_resource.keyvault_secret_update_function_app_id,
│   on resource_linux_function-app.tf line 52, in resource "azapi_update_resource" 
"keyvault_secret_update_function_app_id":
│   52:   body = jsonencode({
│   53:     properties = {
│   54:       value = "test vault"
│   55:     }
│   56:   })
│
│ The value must not be a string
azure terraform
1个回答
0
投票

使用 Terraform azapi 更新密钥保管库机密

根据最新的 terraform_registry 使用 azapi 更新 keyvault 机密应通过直接在正文中传递值来完成,而不是将其作为 json 传递。

示例配置:

resource "azapi_update_resource" "keyvault_secret_update_function_app_id" {
  type        = "Microsoft.KeyVault/vaults/secrets@2022-07-01"
  resource_id = "/subscriptions/subID/resourceGroups/vinay-rg/providers/Microsoft.KeyVault/vaults/testssamplsvksb/secrets/testsample"
  response_export_values = ["*"]

  body = {
    properties = {
      value = "test value"
    }
  }
}

部署:

enter image description here

enter image description here

参考:

azapi_update_resource |资源 |天蓝色/阿扎皮 |地形 | Terraform 注册表

Terraform 注册表

© www.soinside.com 2019 - 2024. All rights reserved.