How To Configure Google Cloud SDK on Mac
Install the Cloud SDK using Homebrew and start managing your projects via CLI
--
The Google Cloud SDK includes a CLI tool and lets developers run gcloud
commands to help manage their projects. Sure, you could always just download and install the SDK directly, or you could skip a few steps and install it using Homebrew as I outline below.
Prerequisites
Make sure you have Python installed (Python 3 (3.5 to 3.8, 3.7 recommended) or Python 2 (2.7.9 or higher)
$ python -v
Make sure you have HomeBrew (and that it’s up to date):
$ brew --version
$ brew update
Install the Cask plugin. If you’re unfamiliar, Cask extends Homebrew and allows you to install large binary files via CLI.
$ brew tap homebrew/cask
Install the Cloud SDK
- Install the SDK via Homebrew
$ brew cask install google-cloud-sdk
2. Add SDK to your shell profile (i.e. ~/.zshrc
)
# GCP SDK
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
3. Verify the installation
$ gcloud version
Google Cloud SDK 365.0.0
bq 2.0.71
core 2021.11.12
gsutil 5.5
4. Authenticate your developer account
$ gcloud auth login
This will open up a browser window, where you can log in to your Google user account. Click Allow to grant permission to access your Google Cloud resource.
Set Up Your Project
- Initialize the Cloud SDK and login if prompted
$ gcloud init
2. Select the Google Cloud project you want to work on
Pick cloud project to use:
[1] [my-project-1]
[2] [my-project-2]
...
Please enter your numeric choice:
3. Choose a compute zone
Which compute zone would you like to use as project default?
[1]…