【问题标题】:ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden]错误: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden]
【发布时间】:2020-09-07 09:31:31
【问题描述】:

基本上,我正在尝试使用我的 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 repositorysource_repository_url的正确写法是什么?

【问题讨论】:

  • 再次尝试将 Cloud Functions 开发人员角色添加到您的 Cloud Build 服务帐号
  • 我已将 Cloud functions DeveloperCloud functions AdminCloud Functions Service AgentService account user 角色添加到我的云构建服务帐户,但仍然遇到相同的错误。
  • 已确认在 us-central1 中部署 Cloud Functions 和 App Engine 存在问题,您可能会受到此影响。 More info here
  • @Pritish 你发现错误了吗?

标签: google-cloud-platform google-cloud-functions google-cloud-build


【解决方案1】:

根据错误信息Permission 'cloudfunctions.functions.get' denied

也许您可以尝试将此权限授予 cloudbuild 默认服务帐户。

cloudbuild 默认服务帐号类似于YOUR_PROJECT_NUMBER@cloudbuild.gserviceaccount.com

【讨论】:

  • 我添加了Cloud functions Admin 角色,但仍然遇到同样的错误。
  • 你是对的。修改了我的 cloudbuild 服务帐户。我已经更新了我的问题。看看我的Edit 部分。
【解决方案2】:

您似乎需要为您的服务帐号授予“项目编辑者”角色。

【讨论】:

    【解决方案3】:

    最可能的原因是没有为Cloud Build 服务启用Cloud Functions Developer 角色。

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

    【讨论】:

      猜你喜欢
      • 2017-04-02
      • 1970-01-01
      • 1970-01-01
      • 2020-08-03
      • 2018-12-31
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 2016-04-05
      相关资源
      最近更新 更多