簡體   English   中英

錯誤: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden]

[英]ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden]

基本上,我正在嘗試使用我的 cloudbuild.yaml 文件部署雲功能:

Cloudbuild.yaml

steps:
- name: 'node:10.10.0'
  id: installing_npm
  args: ['npm', 'install']
  dir: 'API/groups'
- name: 'gcr.io/cloud-builders/gcloud'
  id: deploy
  args: [
          'functions', 'deploy', 'groups', 
          '--region=us-central1',
          '--source=https://source.cloud.google.com/$PROJECT_ID/bitbucket_zebraema_/+/LCM-97_groups_API_test:API/groups', 
          '--trigger-http', 
          '--runtime=nodejs8', 
          '--entry-point=App', 
          '--allow-unauthenticated',
          '--service-account=xaxaxax@appspot.gserviceaccount.com'
        ]
  dir: 'API/groups'

以下是錯誤:

Step #0 - "installing_npm": npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Step #0 - "installing_npm": 
Step #0 - "installing_npm": added 448 packages from 284 contributors and audited 449 packages in 9.697s
Step #0 - "installing_npm": found 5 low severity vulnerabilities
Step #0 - "installing_npm":   run `npm audit fix` to fix them, or `npm audit` for details
Finished Step #0 - "installing_npm"
Starting Step #1 - "deploy"
Step #1 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "deploy": ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[Permission 'cloudfunctions.functions.get' denied on resource 'projects/xxxxxxxxxxxxxxxx/locations/us-central1/functions/groups' (or resource may not exist).]
Finished Step #1 - "deploy"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

編輯:我已將雲功能開發人員、雲功能管理員、雲功能服務代理和服務帳戶用戶角色添加到我的雲構建服務帳戶。

Cloudbuild.yaml

steps:
    - name: 'node:10.10.0'
      id: installing_npm
      args: ['npm', 'install']
      dir: 'API/groups'
    - name: 'gcr.io/cloud-builders/gcloud'
      id: deploy
      args: [
              'functions', 'deploy', 'groups', 
              '--region=us-central1',
              '--source=https://source.cloud.google.com/$PROJECT_ID/bitbucket_zebraema_/+/LCM-97_groups_API_test:API/groups', 
              '--trigger-http', 
              '--runtime=nodejs8', 
              '--entry-point=App', 
              '--allow-unauthenticated',
              '--service-account=$PROJECT_ID@cloudbuild.gserviceaccount.com'
            ]
      dir: 'API/groups'

以下日志:

Step #0 - "installing_npm":   run `npm audit fix` to fix them, or `npm audit` for details
Finished Step #0 - "installing_npm"
Starting Step #1 - "deploy"
Step #1 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "deploy": ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Bad Request], message=[The request has errors
Step #1 - "deploy": Problems:
Step #1 - "deploy": source_repository_url:
Step #1 - "deploy": Source repository URL is invalid https://source.cloud.google.com/xyxyxyxyx/bitbucket_zebraema/LCM-97_groups_API_test/API/groups/src does not match the expected pattern, which is https://source.developers.google.com/projects/{PROJECT_ID}/repos/{REPOSITORY_ID}/revisions/{REVISION_ID}/paths/{PATH} or https://source.developers.google.com/projects/{PROJECT_ID}/repos/{REPOSITORY_ID}/moveable-aliases/{BRANCH_ID}/paths/{PATH} or https://source.developers.google.com/projects/{PROJECT_ID}/repos/{REPOSITORY_ID}/fixed-aliases/{TAG_ID}/paths/{PATH}. Note that PROJECT_ID, REPOSITORY_ID, REVISION_ID, BRANCH_ID, and TAG_ID can not contain '/'. PATH may contain '/'.
Step #1 - "deploy": ]
Finished Step #1 - "deploy"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

在這里,我已將我的bitbucket存儲庫鏡像到我的google cloud source repository中。 編寫source_repository_url的正確方法是什么?

最可能的原因是未為Cloud Build服務啟用Cloud Functions Developer角色。

  1. 導航到 Cloud Build > 設置
  2. 啟用 Cloud Functions 開發人員角色

在此處輸入圖像描述

根據錯誤消息Permission 'cloudfunctions.functions.get' denied

也許您可以嘗試將此權限授予 cloudbuild 默認服務帳戶。

cloudbuild 默認服務帳戶類似於YOUR_PROJECT_NUMBER@cloudbuild.gserviceaccount.com

您似乎需要將“項目編輯”角色授予您的服務帳戶。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM