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

使用特定服务帐户部署功能时,(gcloud.functions.deploy)权限被拒绝,function,deployment,gcloud,Function,Deployment,Gcloud,我正在尝试使用不同的服务帐户部署Google云功能。我将服务帐户属性保存到json文件中。我交换了这些值以使其更易于阅读 export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keys/mynewserviceaccount.json" gcloud functions deploy MyFunction \ --runtime python37 \ --entry-point MyFunction \ --source src \ --service

我正在尝试使用不同的服务帐户部署Google云功能。我将服务帐户属性保存到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}" &
mynewserviceaccount具有以下角色。我尝试过其他一些,但都没有成功。 -云功能管理 -云功能服务代理 -错误编写器 -服务帐户用户 -日志编写器 -发布/订阅用户

我也跑过 gcloud身份验证激活服务帐户mynewserviceaccount@appspot.gserviceaccount.com--密钥文件“/path/to/keys/mynewserviceaccount.json”

当我运行此程序时,我得到: 错误:(gcloud.functions.deploy)ResponseError:status=[403],code=[禁止],message=[调用方没有权限]

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

云上功能声明,如果要使用服务帐户部署功能,必须执行额外的步骤


您必须在云功能运行时服务帐户上为用户分配IAM服务帐户用户角色(roles/IAM.serviceAccountUser)

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

  • 导航到云构建>设置
  • 启用云功能开发人员角色

  • 请参阅:这说明您必须执行额外的步骤。在云功能运行时服务帐户上为用户分配IAM服务帐户用户角色(roles/IAM.serviceAccountUser)。你已经做了吗?这很有效。谢谢将此UI移动到更容易发现的位置会很有用。发布了正式答案,请将其标记为正确,以供其他人查看。很高兴我帮了忙