How to change the project in GCP using CLI commands

前端 未结 16 1897
爱一瞬间的悲伤
爱一瞬间的悲伤 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:50

    I'm posting this answer to give insights into multiple ways available for you to change the project on GCP. I will also explain when to use each of the following options.


    Option 1: Cloud CLI - Set Project Property on Cloud SDK on CLI

    Use this option, if you want to run all Cloud CLI commands on a specific project.

    gcloud config set project 
    

    With this, the selected project on Cloud CLI will change, and the currently selected project is highlighted in yellow.


    Option 2: Cloud CLI - Set Project ID flag with most Commands

    Use this command if you want to execute commands on multiple projects. Eg: create clusters in one project, and use the same configs to create on another project. Use the following flag for each command.

    --project 
    

    Option 3: Cloud CLI - Initialize the Configurations in CLI

    This option can be used if you need separate configurations for different projects/accounts. With this, you can easily switch between configurations by using the activate command. Eg: gcloud config configurations activate .

    gcloud init
    

    Option 4: Open new Cloud Shell with your preferred project

    This is preferred if you don't like to work with CLI commands. Press the PLUS + button for a new tab.

    Next, select your preferred project.

提交回复
热议问题