【发布时间】:2019-01-24 22:12:59
【问题描述】:
我正在尝试从这个 repo 部署代码:
https://github.com/anishkny/puppeteer-on-cloud-functions
在 Google Cloud Build 中。我的 cloudbuild.yaml 文件内容是:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['beta', 'functions', 'deploy', 'screenshot', '--trigger-http', '--runtime', 'nodejs8', '--memory', '1024MB']
我已为我的 Cloud Build Service 帐户 (****@cloudbuild.gserviceaccount.com) 指定了以下角色:
- Cloud Build 服务帐号
- 云函数开发者
然而,在我的 Cloud Build 日志中,我看到以下错误:
starting build "1f04522c-fe60-4a25-a4a8-d70e496e2821"
FETCHSOURCE
Fetching storage object: gs://628906418368.cloudbuild-source.googleusercontent.com/94762cc396ed1bb46e8c5dbfa3fa42550140c2eb-b3cfa476-cb21-45ba-849c-c28423982a0f.tar.gz#1534532794239047
Copying gs://628906418368.cloudbuild-source.googleusercontent.com/94762cc396ed1bb46e8c5dbfa3fa42550140c2eb-b3cfa476-cb21-45ba-849c-c28423982a0f.tar.gz#1534532794239047...
/ [0 files][ 0.0 B/ 835.0 B]
/ [1 files][ 835.0 B/ 835.0 B]
Operation completed over 1 objects/835.0 B.
tar: Substituting `.' for empty member name
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
ERROR: (gcloud.beta.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[The caller does not have permission]
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/gcloud" failed: exit status 1
我错过了什么?
【问题讨论】:
-
您是如何将角色分配给服务帐户的?我写了一篇类似的帖子,我打电话告诉你以下形式的内容应该提供正确的角色:
NUM=$(gcloud projects describe $PROJECT \ --format='value(projectNumber)') gcloud projects add-iam-policy-binding ${PROJECT} \ --member=serviceAccount:${NUM}@cloudbuild.gserviceaccount.com \ --role=roles/cloudfunctions.developer(medium.com/google-cloud/…) -
@DazWilkin 我从 GCP Console IAM 页面 (console.cloud.google.com/iam-admin/iam) 分配了角色。那么,您的 **@cloudbuild.gserviceaccount.com 服务帐号会在 GCP Console 中显示哪些角色?
标签: google-cloud-functions google-cloud-build