How to change the project in GCP using CLI commands

前端 未结 16 1706
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 18:07

How can i change the current running project to another project in GCP (Google Cloud Platform) account using cli commands other than using

16条回答
  •  盖世英雄少女心
    2021-01-29 18:53

    You should actually use the project ID and not the name as the other answers imply.

    Example:

    gcloud projects list
    
    PROJECT_ID              NAME                  PROJECT_NUMBER
    something-staging-2587  something-staging     804012817122
    something-production-24 something-production  392181605736
    

    Then:

    gcloud config set project something-staging-2587
    

    It's also the same thing when using just the --project flag with one of the commands:

    gcloud --project something-staging-2587 compute ssh my_vm
    

    If you use the name it will silently accept it but then you'll always get connection or permission issues when trying to deploy something to the project.

提交回复
热议问题