(gcloud.functions.deploy) 使用特定服务帐户部署功能时权限被拒绝

Dan*_*ill 3 deployment function gcloud

我正在尝试使用不同的服务帐户部署 Google Cloud Functions。我将服务帐户属性保存到 json 文件中。我交换了值以使其更易于阅读。

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keys/mynewserviceaccount.json"

gcloud functions deploy MyFunction \
--runtime python37 \
--entry-point MyFunction \
--source src \
--service-account mynewserviceaccount@appspot.gserviceaccount.com \
--verbosity debug \
--stage-bucket staging.projectname.appspot.com \
--trigger-event providers/cloud.firestore/eventTypes/document.write \
--trigger-resource "projects/projectname/databases/(default)/documents/User/{userId}" &
Run Code Online (Sandbox Code Playgroud)

mynewserviceaccount 具有以下角色。我已经尝试了其他一些,但都没有成功。- 云函数管理员 - 云函数服务代理 - 错误编写器 - 服务帐户用户 - 日志编写器 - 发布/订阅订阅者

我还运行了 gcloud auth activate-service-account mynewserviceaccount@appspot.gserviceaccount.com --key-file "/path/to/keys/mynewserviceaccount.json"

当我运行这个时,我得到:错误:(gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[调用者没有权限]

当我尝试在角色列表中查找“gcloud.functions.deploy”时,我没有看到它。我不知道这是文档问题还是代码问题。

use*_*505 8

如果这是在运行gcloud builds submit命令时发生的,最可能的原因是Cloud Functions Developer没有为该服务启用角色Cloud Build

  1. 导航到云构建 > 设置
  2. 启用 Cloud Functions 开发人员角色

在此输入图像描述


Lou*_*s C 6

文件在云功能的状态,如果要部署与服务功能帐户,您需要做一个额外的步骤。

您必须为用户分配 Cloud Functions Runtime 服务账户上的 IAM 服务账户用户角色 (roles/iam.serviceAccountUser)