Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mcrmonkey/bash-my-gcp

Tools and aliases for gcloud in bash
https://github.com/mcrmonkey/bash-my-gcp

bash bash-script cloud cloud-computing gcp google-cloud google-cloud-sdk zsh-plugin

Last synced: 8 days ago
JSON representation

Tools and aliases for gcloud in bash

Awesome Lists containing this project

README

        

# bash-my-gcp

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](https://github.com/bash-my-universe/bash-my-aws) project.

Why not give this a try:
[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.png)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/mcrmonkey/bash-my-gcp&tutorial=cloudshell-tutorial.md)

**Note**
To aid with compatability in zsh some command names have recently changed.
Please see below for more information.

## Requirements

* [Google Cloud SDK](https://cloud.google.com/sdk/docs/quickstart-linux)
* [bash](https://www.gnu.org/software/bash/)
or
* [zsh](https://www.zsh.org/)

## Installation

Ensure you have the cloudsdk installed on your system and you have it in
a working state

Clone this repository:

```sh
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:

```sh
make install
```

or add the following line to your bashrc file manually:

```sh
. /path/to/bash-my-gcp/loader.sh
```

You can also run the above line manually as and when you need it

## Usage

The following commands are available:

### Configuration profile operations

#### `gcpro [config profile]`

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:

```sh
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:

```sh
gcloud topic configurations
```

#### `gcp-id`

Display the current project ID

#### `gcpro-create `

Create a new configuration profile

* `` - Name of the config profile. e.g.: gaskets-nonprod
* `` - The account you want to use with the project. This account
will be tested against the project as its added.
* `` - The project name

**Note**
This command has recently changed from `gcp-create` to be more consistent with
the zsh changes

### Console operations

#### `gconsole [section]`

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:

```sh
gconsole
```

Open the console in the networking section:

```sh
gconsole net
```

Tab completion is available for this command.

### Cloud DNS operations

#### `gcdns-zones`

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.

#### `gcdns`

List DNS record sets.
**Note**
This has changed from `gcd` for zsh compatibility with git aliases

### Instance operations

#### `gci`

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 :\

#### `gci-status `

Obtain the status of an instance or group of instances.
Fuzzy matching of instance names is available.

#### `gci-start `

Start an instance

Currently only supports one instance name

#### `gci-stop `

Stop an instance

Currently only supports one instance name

#### `gci-zone `

Return the zone for an instance

#### `gci-ips `

List the IP's for an instance

#### `gci-iip `

Show internal IP's for an instance

#### `gci-eip `

Show external IP's for an instance

### Zones and regions

#### `gcr [zone]`

List the available regions with your project quotas and region status along side

#### `gcz [zone]`

List the available zones, the region it lives in and the zones status

### Misc

#### `gssh `

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