代码之家  ›  专栏  ›  技术社区  ›  kotrfa

gCloud-没有任何API的权限,即使我是所有者并且通过Web UI工作正常

  •  1
  • kotrfa  · 技术社区  · 7 年前

    我是我新创建的组织的所有者,我在该组织下创建了一个项目,并将其链接到组织账单帐户,在该帐户中我有1000美元的信用。通过Web用户界面,我可以旋转集群、虚拟机、网络…但当我想通过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用户界面GCP中看到,API显然已经启用(并且可以使用),只是GCloud不允许我使用它们。gCloud下的帐户与我在Web控制台中使用的完全相同-由验证 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,而不是这个组织下的实际项目。

    1 回复  |  直到 7 年前
        1
  •  2
  •   kotrfa    7 年前

    所以问题是我用错了 project_id 什么时候? gcloud config set project 由于某种原因,gcloud默认为组织。

    所以我必须找到正确的项目ID gcloud projects list 然后使用 gcloud config set project {PROJECT-ID} ( 不 项目名称!)