【发布时间】:2022-01-01 22:33:06
【问题描述】:
我最近在 Terraform 中创建了一个 cosmos 数据库,我试图将其数据库连接字符串作为密钥传递给 keyvault,但是这样做时出现以下错误:
Error: Incorrect attribute value type │ │ on keyvault.tf line 282, in resource "azurerm_key_vault_secret" "Authentication_Server_Cosmos_DB_ConnectionString": │ 282: value = azurerm_cosmosdb_account.nsauthsrvcosmosdb.connection_strings │ ├──────────────── │ │ azurerm_cosmosdb_account.nsauthsrvcosmosdb.connection_strings has a sensitive value │ │ Inappropriate value for attribute "value": string required.
我也尝试使用敏感参数,但密钥库不喜欢该参数,我也找不到任何有关如何执行此操作的文档。在 Terraform 网站上,它只是将它列为您可以调用的属性。
我的 Terraform Secret 代码如下,我不会把我所有的代码都放在这里,因为堆栈溢出不喜欢我拥有的代码量。
所以请假设,我使用的是最新的 Azurerm 代理,我的所有其余代码都是正确的,只是无法正常工作的秘密部分。
resource "azurerm_key_vault_secret" "Authentication_Server_Cosmos_DB_ConnectionString" { //Auth Server Cosmos Connection String Secret
name = "AuthenticationServerCosmosDBConnectionString"
value = azurerm_cosmosdb_account.nsauthsrvcosmosdb.connection_strings
key_vault_id = azurerm_key_vault.nscsecrets.id
depends_on = [
azurerm_key_vault_access_policy.client,
azurerm_key_vault_access_policy.service_principal,
azurerm_cosmosdb_account.nsauthsrvcosmosdb,
]
}
【问题讨论】:
-
您想使用连接字符串的任何具体原因?为什么不主键和端点
-
因为 .Net Dev 已将应用程序编程为查找连接字符串。
标签: azure azure-devops terraform azure-cosmosdb azure-keyvault