How to change the project in GCP using CLI commands

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

    It could be that I'm late to answer, but this command made me learn a lot about gcloud SDK

    gcloud alpha interactive

    It's easier to discover by yourself that you'll need gcloud config set project my-project.

    However, what I like about gcloud is tab complication, so if you configure your gcloud config with configurations (I know it sounds weird but run this command gcloud config configurations list) you can easily switch between your own projects that you usually work:

    The alias that I use is: alias gcca="gcloud config configurations activate" and it works fine with zsh gcloud plugin.

    EDIT: To configure one of configurations I usually do this

    gcloud config configurations create [CUSTOM_NAME]
    gcloud auth login # you can also manually set
    gcloud config set project [gcp-project-id]
    gcloud config set compute/zone europe-west3-c
    gcloud config set compute/region europe-west3
    

    You can use ENV variables too but I like when it's configured this way...

提交回复
热议问题