GCP - 云运行 : "Error: The user is forbidden from accessing the bucket"



我正在编写一个GitHub操作,以将我的应用程序部署到GCP的"Cloud Run;服务

name: Deploy to production
on:
push:
branches:
- master
env:
PROJECT_ID: XXX
SERVICE_NAME: XXX
RUN_REGION: XXX
PACKAGE_VERSION : XXX
permissions:
contents: read
id-token: write
jobs:
deployment-job:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v2
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0
with:
workload_identity_provider: XXX
service_account: XXX
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v0
with:
service: ${{ env.SERVICE_NAME }}
source: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ env.PACKAGE_VERSION }} # equivalent to "gcloud builds submit ..."
region: ${{ env.RUN_REGION }}
tag: ${{ env.PACKAGE_VERSION }}

我遇到了这个错误:

ERROR: (gcloud.beta.run.deploy) The user is forbidden from accessing the bucket [XXX]. Please check your organization's policy or if the user has the "serviceusage.services.use" permission

我试图将此权限添加到我的服务帐户,但我仍在运行相同的错误:

gcloud projects add-iam-policy-binding XXX --member=serviceAccount:XXX --role=roles/serviceusage.serviceUsageAdmin

我在本教程中设置了Workload Identity Federation。

存储管理员角色授予服务帐户,而不是Storage Object Admin,以允许您的Github操作使用工作流模板进行部署。

我在将Workload Identity设置为Github Action时遇到了这个错误。错误消息很奇怪,但问题出在工作流模板中。该模板指示您授予存储对象管理权限,但在该模板中链接的必需权限页面中,它表示我们需要授予Storage Admin

您可能还需要授予服务使用消费者角色;我已经有了,所以我不确定是否需要它。

相关内容

最新更新