如何将 GCP IAM 角色添加到服务帐号

Mat*_*nti 4 docker google-cloud-platform docker-swarm docker-machine google-iam

我正在尝试使用 .gcp 在 GCP 上的虚拟机实例上创建 docker swarm 节点docker-machine

docker-machine create swarm-node -d google --google-machine-type e2-standard-2 --google-zone europe-north1-a --google-project myproject-name
Run Code Online (Sandbox Code Playgroud)

我在本地主机 docker-machine CLI 中使用 GCP 服务帐户。

export GOOGLE_APPLICATION_CREDENTIALS="/home/my-name-here/.gcp/path-to-my-service-account-keyfile.json"

但我收到了这个错误:

Error with pre-create check: "Project with ID \"myproject-name\" not found. googleapi: Error 403: Required 'compute.projects.get' permission for 'projects/myproject-name', forbidden"
Run Code Online (Sandbox Code Playgroud)

如何compute.projects.get向 GCP 服务帐号添加 GCP IAM 访问权限?

Mat*_*nti 16

最后我想通了,如下所述:\n https://cloud.google.com/iam/docs/granting-changing-revoking-access

\n
    \n
  1. 在 Cloud Console 中,前往 IAM 页面
  2. \n
  3. 单击添加。
  4. \n
  5. 输入服务帐户电子邮件地址(显示在服务帐户仪表板中)。
  6. \n
  7. 选择一个角色,在本例中Compute Admin
  8. \n
  9. 单击“保存”。
  10. \n
\n

等等\xc3\xa0

\n