gcloud app部署错误需要“vpcaccess.connectors.use”权限

fed*_*odr 8 permissions google-app-engine permission-denied google-cloud-platform

我有 GO 应用程序,并尝试使用 google 命令行 sdk 从具有自定义服务帐户的本地计算机将其部署到 google 应用程序引擎。

\n

我创建一个具有角色的自定义服务帐户:

\n
    \n
  • 应用程序引擎管理员
  • \n
  • 云构建服务帐号
  • \n
  • 云构建服务
  • \n
  • 代理无服务器 VPC 访问用户
  • \n
\n

并使用此帐户进行本地授权:

\n
gcloud auth activate-service-account account_name@project-name.iam.gserviceaccount.com --key-file=key.json\n
Run Code Online (Sandbox Code Playgroud)\n

另外,我在 app.yaml 中配置服务帐户:

\n
service_account: account_name@project-name.iam.gserviceaccount.com\n
Run Code Online (Sandbox Code Playgroud)\n

但是当我尝试部署时

\n
gcloud app deploy -v 1   \n
Run Code Online (Sandbox Code Playgroud)\n

我收到错误:

\n
Beginning deployment of service [default]...\n\xe2\x95\x94\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x97\n\xe2\x95\xa0\xe2\x95\x90 Uploading 0 files to Google Cloud Storage                \xe2\x95\x90\xe2\x95\xa3\n\xe2\x95\x9a\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x9d\nFile upload done.\nERROR: (gcloud.app.deploy) PERMISSION_DENIED: Operation is not allowed. The "vpcaccess.connectors.use" permission is required.\n
Run Code Online (Sandbox Code Playgroud)\n

我不明白为什么即使我拥有无服务器 VPC 访问用户角色,仍然需要 vpcaccess.connectors.use 权限?我在这个谷歌文档页面上找到了这个角色

\n

也许有人遇到过类似的困难?请帮我)

\n

UPD 即使我给予所有者角色我钢也有错误

\n

int*_*cho 12

修复此错误的一种方法是从 app.yaml 中删除vpc_access_connector:配置,但这意味着您的应用程序引擎需要通过 Internet 连接才能访问子网上的资源。

如果您确实需要配置 vpc_access_connector,请将 IAM 角色添加 Serverless VPC Access UserCompute Viewer执行部署的服务账户。将角色添加到配置了 VPC 访问连接器的项目中。

当连接器不存在(或存在于其他地方)时也会出现此错误。

检查 app.yaml 中的项目 ID、区域和连接器名称是否正确,并引用 https://console.cloud.google.com/networking/connectors/list?project= <project_id>中存在的连接器

vpc_access_connector:
  name: projects/project-id/locations/the-zone/connectors/my-connector-name
Run Code Online (Sandbox Code Playgroud)

如果您有共享 VPC,则无服务器访问连接器可以位于宿主项目或服务项目中。请参阅:在共享 VPC 服务项目中配置连接器

如果连接器位于共享 VPC 的宿主项目上,您必须Serverless VPC Access Viewer在宿主项目上授予部署服务帐户 (vpcaccess.viewer) 角色。 Compute Network Viewer还建议在主机上使用 (compute.networkViewer)。


fed*_*odr 3

好的,我通过从 app.yaml 中删除 vpc_access_connector: 配置来修复此错误

UPD 但如果您需要配置 vpc_access_connector,则需要添加无服务器 VPC 访问用户和计算查看者 IAM 角色,并且所有操作都必须正常工作。