如何使用 Terraform 将密钥加载到 IBM KeyProtect

How to load a key into IBM KeyProtect using Terraform

我想使用 IBM Terraform 提供程序来供应包含标准密钥的 KeyProtect 实例。

获取 KeyProtect 实例很容易:使用类型为 kmsservice instance

Terraform 是否提供在 KeyProtect 实例中插入指定密钥的方法?

未测试,但应该可以...;-)

IBM Terraform 提供者只针对云资源,不针对“应用程序数据”。但是,有一个 REST API Provider 允许执行对 REST API 的调用。

IBM Cloud Key Protect 提供了这样的接口并允许 create or import a key. This toolchain deploy script shows an automated way of provisioning Key Protect and creating a new root key (read the security tutorial 此处)。您基本上需要编写类似的代码来获取必要的令牌和其他元数据:

curl -s -X POST $KP_MANAGEMENT_URL \
    --header "Authorization: Bearer $KP_ACCESS_TOKEN" \
    --header "Bluemix-Instance: $KP_GUID" \
    --header "Content-Type: application/vnd.ibm.kms.key+json" -d @scripts/root-enckey.json

更新:

Terraform 提供程序现在有 ibm_kms_key 和一些其他资源。它允许将现有密钥导入 Key Protect 或 Hyper Protect Crypto Services。