bash-my-gcp assists people using Google Cloud Platform services from the command line by providing shorter memorable commands for operating on the Google Cloud platform.
All of these functions and aliases are wrappers around the Google Cloud SDK command line tools.
Please note: Although these scripts make use of Google products and services, these scripts are not endorsed and/or supported by Google themselves. Use at your own risk etc.
This project has been inspired by the bash-my-aws project.
Note To aid with compatability in zsh some command names have recently changed. Please see below for more information.
Ensure you have the cloudsdk installed on your system and you have it in a working state
Clone this repository:
git clone https://www.github.com/mcrmonkey/bash-my-gcp
The scripts will need to be loaded in to your bash session:
If you have make installed run the following to add it to you bashrc file:
make install
or add the following line to your bashrc file manually:
. /path/to/bash-my-gcp/loader.sh
You can also run the above line manually as and when you need it
The following commands are available:
This command handles switching between GCP configuration profiles and is
a wrapper around the gcloud config configurations
command.
Note this has recently changed from gcp
for zsh git alias compatibility.
Example:
gcpro customer-prod
Running the command without arguments will display your configuration profiles and which one of them is active
Tab completion is available for this command.
run the following command to learn more about configuration profiles and how to set them up:
gcloud topic configurations
Display the current project ID
Create a new configuration profile
<config_name>
- Name of the config profile. e.g.: gaskets-nonprod<gcloud_account>
- The account you want to use with the project. This account will be tested against the project as its added.<project_name>
- The project name
Note
This command has recently changed from gcp-create
to be more consistent with
the zsh changes
This command will open the cloud console on either the home page or the specified section i.e. networks
TODO: This command probably needs a better way of starting a browser that is fully compatible with all/vast majority of linux distributions. If your distro doesn't have xdg-open ( Part of Gnome ) the URL will be dropped in your terminal.
This command currently requires the project ID to be set in your configuration profile.
Examples:
Open the console home page for the current project:
gconsole
Open the console in the networking section:
gconsole net
Tab completion is available for this command.
List or describe managed zones.
Tab completion is available for this command.
Note
This has changed from gcd-zones
in light of the changes to the gcd
command
so that it is more consistent.
List DNS record sets.
Note
This has changed from gcd
for zsh compatibility with git aliases
This command will list the current instances and their state in the currently loaded project in a fancy table.
--filter
is available and will fuzzy match instances. --filter="this AND that"
will fail however due to a bug :\
Obtain the status of an instance or group of instances. Fuzzy matching of instance names is available.
Start an instance
Currently only supports one instance name
Stop an instance
Currently only supports one instance name
Return the zone for an instance
List the IP's for an instance
Show internal IP's for an instance
Show external IP's for an instance
List the available regions with your project quotas and region status along side
List the available zones, the region it lives in and the zones status
Wrapper around ssh command to funnel host key ID's in to knownhost file suffixed with the project ID eg: ~/.ssh/known_hosts-abc-prod-1234