简体   繁体   English

将 OCI Terraform 提供程序变量作为机密存储在 Azure Key Vault 中并通过 Azure DevOps Pipeline 执行

[英]Store OCI Terraform Provider Variables as Secrets in Azure Key Vault and Execute via Azure DevOps Pipeline

I'm using Azure Key Vault, Git and DevOps Pipelines and my intention is to execute Terraform code against Oracle Cloud Infrastructure (OCI).我正在使用 Azure Key Vault、Git 和 DevOps Pipelines,我的目的是针对 Oracle 云基础设施 (OCI) 执行 Terraform 代码。 I've configured the necessary resource group, storage account, container, uploaded the OCI provider variables into Key Vault.我已配置必要的资源组、存储帐户、容器,并将 OCI 提供程序变量上传到 Key Vault。

I've tried storing the API signing key as a secret, and as a key, but Terraform throws provider-related errors regarding the private key.我尝试将 API 签名密钥存储为秘密和密钥,但 Terraform 会引发与私钥相关的提供程序相关错误。 I'm looking for the proper way to get the content of the private key from Azure Key Vault and pass it to the OCI provider.我正在寻找从 Azure Key Vault 获取私钥内容并将其传递给 OCI 提供程序的正确方法。 Or just the proper way to leverage Key Vault with the OCI provider.或者只是通过 OCI 提供程序利用 Key Vault 的正确方法。

This is the error I'm getting during Terraform Plan:这是我在 Terraform 计划期间遇到的错误:

Error: Incorrect attribute value type.错误:属性值类型不正确。 Inappropriate value for attribute "private_key": string required.属性“private_key”的值不合适:需要字符串。

My code looks as follows:我的代码如下所示:

provider "oci" {
  ### Tenancy Connectivity variables
  tenancy_ocid = "${data.azurerm_key_vault_secret.tenancy-ocid.value}"
  user_ocid    = "${data.azurerm_key_vault_secret.dev-user-ocid.value}"
  fingerprint  = "${data.azurerm_key_vault_secret.key-fprint.value}"
  private_key = "${data.azurerm_key_vault_key.oci-private-key}"
  private_key_password = ""
  region = var.home_region
}

The Terraform Plan operation only seems to complain about the private key, while the other secrets are read successuflly. Terraform Plan 操作似乎只抱怨私钥,而其他秘密被成功读取。 Any help would be appreciated!任何帮助,将不胜感激!

For the first three pairs, you retrieve the value, which is translated to a string.对于前三对,您检索转换为字符串的值。 The provider is not complaining, as these are accepted values.提供者没有抱怨,因为这些是可接受的值。

However, it looks like for the private key, you are not passing the key contents (value attribute might be missing).但是,对于私钥,您没有传递密钥内容(可能缺少值属性)。 I am no expert in how to retrieve the contents of the private key from Azure, but you have to pass the "value" of the key...我不是如何从 Azure 中检索私钥内容的专家,但您必须传递密钥的“值”...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM