当您使用 gcloud 命令行界面创建 Google Cloud 服务帐户时,会出现 gcloud iam service-accounts keys create
创建一个 key 。在 Web 控制台中查看,该命令似乎创建并注册了该帐户的 key 。
这足以激活服务帐户以与他们生成的 JSON key 文件一起使用吗?或者您是否还必须调用:
gcloud auth activate-service-account <IAM> --key-file=<JSON file from the keys create command>
关于最后一步是否必要,Google 文档在这里有点不清楚。控制台未显示对服务帐户的任何更改,但如果您确实进行了调用,该命令会成功执行。
最佳答案
通过 gcloud iam service-accounts keys create
创建 key 不会立即使其可用于 gcloud 命令。您确实需要通过 gcloud auth activate-service-account
激活.
用
gcloud auth list
查看您的凭据集。此外,gcloud 使用当前有效的凭据。您可以通过运行查看当前设置
gcloud config list
也可以通过添加额外的
--account
来使用各种凭据。标记到任何 gcloud
命令。例如:gcloud compute zones list --account my_account@gmail.com
以前通过
gcloud auth login
获得帐户的地方或 gcloud auth activate-service-account
并出现在 gcloud auth list
.
关于google-cloud-platform - 创建 Google Cloud 服务帐号时,是否需要在创建 key 后对其进行授权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45154422/