Switch
Managing Google Cloud projects across several accounts often involves a cumbersome process of executing multiple gcloud
commands. This can be both time-consuming and error-prone. I made Switch to simplify and streamline this process.
Why Use Switch?
Before Switch:
Switching between Google Cloud accounts and projects requires executing a series of commands (if you want to set and confirm their values were applied):
gcloud config set account $account
gcloud config set project $project
gcloud config get-value account
gcloud config get-value project
This method, while effective, was not user-friendly and posed challenges for me in remembering specific account and project details.
After Switch:
Switch transforms this multi-step process into a memorable one-command action. Hereβs how it works:
- Create a Shortcut (One Time Process):
switch create myShortcut
- Execute the Shortcut:
switch myShortcut
This process makes executing all the necessary commands more efficient and displays a description of the project(s) running on the account after you switch. Itβs helpful for someone like me who needs to manage multiple server configurations on gCloud and doesn't frequently interact with the infrastructure enough to remember what's running on each of them.
Features of Switch
- Shortcut Management: Easily create, update, and remove shortcuts for your Google Cloud configurations.
- Display Information: Get detailed information about all your configured shortcuts, the Google accounts they are associated with, the SSH commands and IP addresses for each VM shortcut and details about what's running on them. An asterisk (*) appears next to the currently active shortcut.
- Quickly Switch Profiles: Execute shortcuts to rapidly switch between different Google Cloud configurations and associated metadata. For instance, after typing
switch myShortcutName
a command likeswitch ssh
can SSH into that configurations VM using its respective SSH key, username and IP address. - Data Backup and Portability: Export and import Switch configurations, making configurations portable across different machines.
For individuals juggling various personal and professional projects on Google Cloud, Switch provides a practical solution for managing them. It simplifies a complicated set of commands into an easy-to-remember shortcut, enhancing productivity and minimizing the risk of errors. I find this little utility useful and maybe you will too!