gpt4 book ai didi

google-cloud-platform - 通过 GCP 控制台运行 Cloud Build 触发器返回 'build.service_account' 无法为触发build设置字段

转载 作者:行者123 更新时间:2023-12-05 02:40:57 24 4
gpt4 key购买 nike

我目前正在为我的 Dataflow Flex 模板使用 Cloud Build 来启 Action 业。这是我当前的命令:

gcloud beta builds submit --config run.yaml --substitutions _REGION=$REGION \
--substitutions _FMPKEY=$FMPKEY --no-source

目前这在 Cloud Shell 中运行良好。但现在我希望基于触发器启动构建。因此,我创建了一个 Cloud Build,它将根据向主题发送消息来触发运行此文件:

https://github.com/mmistroni/GCP_Experiments/blob/master/dataflow/pipeline/run.yaml

但是,在向所选主题发布消息后,我的所有构建都失败并出现以下错误:

our build failed to run: generic::invalid_argument:generic::invalid_argument:
'build.service_account' field cannot be set for triggered builds

我看不到任何日志或详细信息,所以我不清楚发生了什么......我猜这与我的 run.yaml 中的最后一行有关?

options:
logging: CLOUD_LOGGING_ONLY

# Use the Compute Engine default service account to launch the job.
serviceAccount: projects/$PROJECT_ID/serviceAccounts/$PROJECT_NUMBER-compute@developer.gserviceaccount.com

但是我看不到在云构建中选择服务帐户的选项。我需要在 IAM 中设置一些权限吗?

最佳答案

您的猜测是正确的,这是按预期工作的。

Cloud Build 有一个默认服务帐户来代表您执行构建。虽然 GCP 允许您配置特定于用户的帐户以进行额外控制,但在您使用构建触发器时它并不适用。构建触发器仅使用默认服务帐户来执行构建。

这记录在 GCP docs 中:

Build triggers use Cloud Build service account to execute builds. This could provide elevated build-time permissions to users who use triggers to start a build. Keep the following security implications in mind when using build triggers ...

也是 limitation 的一部分:

User-specified service accounts only work with manual builds; they don't work with build triggers.

因此,如果您计划使用构建触发器,则必须传递不带 serviceAccount 的配置 yaml。

关于google-cloud-platform - 通过 GCP 控制台运行 Cloud Build 触发器返回 'build.service_account' 无法为触发build设置字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68351798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com