简体   繁体   中英

How to rename existing 'named configurations' using gcloud cli in GCP?

I would like to know if there is a way to rename an existing 'gcloud topic configurations' eg I would like rename 'foo' to 'bar' in the below example.

I couldn't find anything on this in the gcloud reference documents.

在此处输入图片说明

Technically, it is not possible to change the name of that configuration using the gcloud command.

However, you can change it doing this little workaround:

  • Use gcloud config configurations activate [YOUR_CONFIG_NAME] to activate the configuration you wish.
  • Use gcloud info --format='get(config.paths.active_config_path)' to find the directory where your configurations are stored. You will get the path of the file of that specific configuration, looking like this /tmp/tmp.XAfddVDdg/configurations/[YOUR_CONFIG_NAME]
  • If you cd into the directory /tmp/tmp.XAfddVDdg/configurations/ , you will find all your configurations there. Every configuration will be named there like this config_[YOUR_CONFIG_NAME] . Modifying the part that matches the name of your configuration will successfully change its name. DO NOT delete the config_ part of the name.
  • After this, is you print all the configurations using gcloud config configurations list , you will find your configuration renamed, but none will be active now. Just activate it with gcloud config configurations activate [YOUR_CONFIG_NAME] , and you will be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM