我是我新创建的组织的所有者,我在该组织下创建了一个项目,并将其链接到我的信用额度为1000 $的组织计费帐户中。通过Web UI,我可以启动集群,VM,网络...但是当我想通过gcloud进行启动时,我的权限被拒绝了。例如:
$ gcloud compute networks list
API [compute.googleapis.com] not enabled on project [XXX].
Would you like to enable and retry (this will take a few minutes)?
(y/N)? y
ERROR: (gcloud.compute.networks.create) PERMISSION_DENIED: The caller does not have permission
但是我可以在Web UI GCP中看到该API已明确启用(并且可以使用),只是gcloud不允许我使用它们。 gcloud下的帐户与我在网络控制台中使用的帐户完全相同-已通过gcloud auth list
验证:
$ gcloud config configurations describe myproject
is_active: true
name: myproject
properties:
compute:
region: europe-west1
zone: europe-west1-b
core:
account: <my-email>
project: <the-project-I-want>
或
$ gcloud services list
ERROR: (gcloud.services.list) User [<myusername>] does not have permission to access project [myproject] (or it may not exist): The caller does not have permission
使用不同的帐户(和不同的组织/项目)完全可以正常工作,但是我过去没有设置该帐户。我该怎么办?非常感谢!
更新:
gcloud init
之后,至少gcloud services list
开始工作。但是其他人没有:
$ gcloud services list
NAME TITLE
bigquery-json.googleapis.com BigQuery API
cloudapis.googleapis.com Google Cloud APIs
clouddebugger.googleapis.com Stackdriver Debugger API
cloudtrace.googleapis.com Stackdriver Trace API
compute.googleapis.com Compute Engine API
container.googleapis.com Kubernetes Engine API
containerregistry.googleapis.com Container Registry API
datastore.googleapis.com Cloud Datastore API
logging.googleapis.com Stackdriver Logging API
monitoring.googleapis.com Stackdriver Monitoring API
oslogin.googleapis.com Cloud OS Login API
pubsub.googleapis.com Cloud Pub/Sub API
servicemanagement.googleapis.com Service Management API
serviceusage.googleapis.com Service Usage API
sql-component.googleapis.com Cloud SQL
storage-api.googleapis.com Google Cloud Storage JSON API
storage-component.googleapis.com Google Cloud Storage
$ gcloud compute networks create testing-net --subnet-mode=custom '--description=Network to host testing kubernetes cluster'
API [compute.googleapis.com] not enabled on project [{PROJECT_ID}].
Would you like to enable and retry (this will take a few minutes)?
(y/N)? y
ERROR: (gcloud.compute.networks.create) PERMISSION_DENIED: The caller does not have permission
^上面的PROJECT_ID
显示了我组织的ID,而不是该组织下的实际项目。
答案 0 :(得分:2)
所以问题是当project_id
和gcloud由于某种原因默认为组织时,我使用了错误的gcloud config set project
。
所以我不得不使用gcloud projects list
找到正确的项目ID,然后使用gcloud config set project {PROJECT-ID}
(不是项目名称!)