【发布时间】:2022-10-16 10:30:44
【问题描述】:
我想做的事
我已经将我的私有 npm 包发布到 Artifact Registry 上,下图就是我想要做的。
基本上我想使用来自project-staging 和project-production 的私有包。所以我的package.json 看起来像:
"dependencies": {
"@<scope>/private_package": "^1.0.0",
},
我做了什么
授予 Cloud Build 服务帐号权限
我在 project-common 的 IAM 菜单下向 <project-staging_id>@cloudbuild.gserviceaccount.com 和 <project-production_id>@cloudbuild.gserviceaccount.com 授予了 artifactregistry.reader 权限。
.npmrc准备工作
cd path/to/project_directory
gcloud artifacts print-settings npm \
--project=project-common \
--repository=private_package \
--location=<location> \
--scope=@<scope>
vim .npmrc
# => add the output of above gcloud command
npx google-artifactregistry-auth .npmrc
部署
gcloud config configurations activate project-staging
gcloud functions deploy <function_name> --gen2 --region=<region> --trigger-http --runtime=nodejs16 --entry-point=<entry_point>
这给了我以下错误。
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed with status: FAILURE and message: npm ERR! code E403
npm ERR! 403 403 Forbidden - GET https://<URL>.tgz - Permission "artifactregistry.repositories.downloadArtifacts" denied on resource "<resource_name>" (or it may not exist)
我不知道为什么我会得到这个,即使
<project-staging_id>@cloudbuild.gserviceaccount.com 拥有 artifactregistry.reader 权限。
还有什么我应该做的吗?
【问题讨论】:
标签: node.js google-cloud-platform google-cloud-functions google-artifact-registry