Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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' e.g. I would like rename 'foo' to 'bar' in the below example.

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

enter image description here

like image 460
jayBana Avatar asked Mar 13 '19 10:03

jayBana


People also ask

How can I change gcloud CLI project?

Check the available projects by running: gcloud projects list . This will give you a list of projects which you can access. To switch between projects: gcloud config set project <project-id> . Show activity on this post.

Where are gcloud configurations stored?

Configurations are stored in your user config directory (typically ~/. config/gcloud on MacOS and Linux, or %APPDATA%\gcloud on Windows); you can find the location of your config directory by running gcloud info --format='value(config. paths.

How do I rename a virtual machine in Google cloud?

Before renaming the instance, stop it by using the gcloud compute instances stop command. After renaming, start the instance by using the gcloud compute instances start command. Replace the following: INSTANCE_NAME : name of the instance to rename.

How do I change gcloud settings?

You can change it by running [gcloud config set compute/zone NAME]. Your project default Compute Engine region has been set to [us-west1]. You can change it by running [gcloud config set compute/region NAME].


1 Answers

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.
like image 60
Pablo Almécija Rodríguez Avatar answered Sep 20 '22 20:09

Pablo Almécija Rodríguez