【问题标题】:Error submitting Cloudbuild job from Cloudfunctions if从 Cloud Functions 提交 Cloud Build 作业时出错,如果
【发布时间】:2026-01-03 09:25:18
【问题描述】:

希望这对于比我知识更深的人来说是一个简单的...

我有一个 Cloudfunction,它响应 webhook 调用以使用 API 将作业提交到 Cloudbuild。这很好用,只是现在我们有一些工作需要使用来自不同项目的 KMS 密钥。

secrets:
- kmsKeyName: projects/xxx/locations/global/keyRings/xxx/cryptoKeys/xxx

在 cloudbuild.yaml 中包含此内容后,提交 Cloudbuild 作业的 api 调用返回:

400 invalid build: failed to check access to "projects/xxx/locations/global/keyRings/xxx/cryptoKeys/xxx"

我已尝试将 Cloudfunction 和 Cloudbuild 服务帐户从调用帐户添加到托管 KMS 的帐户中,包括所有者。

This 文章有简单明了的说明,用于在另一个帐户中访问 Container Registry 和其他服务,但没有关于 KMS 的内容。这个错误似乎不会在搜索中触发任何有意义的结果,而且我一点也不熟悉。

感谢您的帮助。

【问题讨论】:

    标签: google-cloud-platform google-cloud-functions google-cloud-build google-cloud-kms


    【解决方案1】:

    未在运行 Cloudbuild 的项目上启用 Cloud KMS API。不幸的是,错误信息是如此模糊。事实上,我通过在 Cloudbuild 作业中运行 gcloud kms decrypt ... 来诊断问题,这有助于告诉我需要启用 API。

    【讨论】: