kee*_*mel 6 google-cloud-platform google-cloud-kms google-cloud-build
我正在尝试创建一个 Cloud Build 触发器,其中使用 Cloud KMS 对秘密环境变量进行加密并存储为 Cloud Build 中的替换变量。这样我的云构建 yaml 是相当通用的,并且在我们部署到的所有环境中都是相同的。
这个云构建 yaml 工作正常:
steps:
- name: 'ubuntu'
entrypoint: 'bash'
args: ['-c', 'echo "$$APP_NAME HAS A VALUE $$HELLO_WORLD"']
env:
- 'APP_NAME=${_APP_NAME}'
secretEnv:
- 'HELLO_WORLD'
secrets:
- kmsKeyName: 'projects/my-first-cicd-project/locations/europe-west1/keyRings/keyring-dev/cryptoKeys/key-backend'
secretEnv:
HELLO_WORLD: xxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
构建步骤生成此日志行:
My App Name HAS A VALUE Hello there world!
Run Code Online (Sandbox Code Playgroud)
完全符合预期。
现在对于不起作用的事情,或者至少我无法上班。假设我想让密钥环名称动态化。然后我将该 yaml 中的“keyring-dev”替换为${_KMS_KEYRING_NAME}. 这将产生如下错误:
invalid build: failed to check access to "projects/my-first-cicd-project/locations/europe-west1/keyRings/${_KMS_KEYRING_NAME}/cryptoKeys/key-backend"
Run Code Online (Sandbox Code Playgroud)
如果我将 YAML 中的 base64 字符串(以“CiQAH...”开头)更改为诸如 ${_KMS_VAR_HELLO_WORLD} 之类的替换变量,我将收到此错误:
failed unmarshalling build config cloudbuild.yaml: illegal base64 data at input byte 0
Run Code Online (Sandbox Code Playgroud)
仅供参考:base64 字符串的值不超过变量值的最大字符数 255。
所以我的猜测是,Cloud Build 不会替换 cloudbuild.yaml 的 secrets 部分中的任何内容。有谁知道这个问题的解决方案?
这是 API 的已知限制。
| 归档时间: |
|
| 查看次数: |
1253 次 |
| 最近记录: |