當我們想要建立 Cloud Run 的容器映像時, 可以使用 gcloud builds submit
gcloud builds submit --tag gcr.io/andy-prj/my-service --project $PROJECT
若執行的過程中若出現以下的錯誤訊息時
Creating temporary tarball archive of 124 file(s) totalling 570.2 KiB before compression.
Uploading tarball of [.] to [gs://andy-prj_cloudbuild/source/3422.582116-0fd81c021c243d892201dfd08ce1550.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/andy-prj/builds/46712e03-3a15-403f-8be1-b1f1a238d02e].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/46712e03-3a15-403f-8be1-b1f1a238d02e?project=182871].
ERROR: (gcloud.builds.submit) HTTPError 403: <?xml version='1.0' encoding='UTF-8'?><Error><Code>AccessDenied</Code><Message>Access denied.</Message><Details>deploy-cloud@andy-prj.iam.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object.</Details></Error>
表示需要我們缺少存取 GCS 裡物件的權限
要解決這個問題, 可以到 IAM 的頁面下加入 Viewer 的權限如下
留言
張貼留言