Google Cloud SDK provides tools to access Google Cloud Platform product and services. Most users have more than one project and Google Cloud Platform. Learn how install and setup SDK and how to create configurations so that work on multiple projects is easy and effective
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Setting Google Cloud SDK for multiple projects
1. Setting Google Cloud SDK
for multiple projects
Zdenko Hrcek
https://the-swamp.info
zdenulo@gmail.com
@zdenulo
+ZdenkoHrcek
2. Content
● What is Google Cloud SDK
● Installation and Setup
● Working with gcloud configurations
3. Google Cloud SDK
● Command-line interface for Google Cloud Platform products and services
● Create Google Compute Engine instances, upload files to Google Cloud
Storage, configure Network, deploy Google App Engine apps etc.
● It has emulators for Datastore, Pub/Sub, App Engine libraries, Kubernetes
● Good to use in automation scripts (bash)
4. Install (on Linux)
https://cloud.google.com/sdk/docs/quickstart-linux
Download installation files, unpack and install:
155.0.0 is Google Cloud SDK version
>wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
>tar -zxvf google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
>cd google-cloud-sdk
>./install.sh
5. Setup
login to your Google Account and grant appropriate permissions, then select existing project and create
new one
You are logged in as: [youremail@gmail.com].
Pick cloud project to use:
[1] existing-project-1
[2] existing-project-2
[3] Create a new project
Please enter numeric choice or text value (must exactly match list)
>gcloud init
6. Creating configuration (for multiple projects)
Configuration is set of properties/configurations like account email, project id, etc.
Convenient way is to have configuration for every project and switch between
Create new configuration called test-config
It automatically switches/activates new configuration
>gcloud config configurations create test-config
Created [test-config].
Activated [test-config].
7. Set created configuration (for multiple projects)
Set google cloud project id and other stuff (like Compute Engine zone) for this (active) configuration
>gcloud init
Welcome! This command will take you through the configuration of gcloud.
Settings from your current configuration [test-config] are:
[core]
disable_usage_reporting = False
Your active configuration is: [test-config]
Pick configuration to use:
[1] Re-initialize this configuration [test-config] with new settings
[2] Create a new configuration
[3] Switch to and re-initialize existing configuration: [default]
Please enter your numeric choice: 1
8. List all configurations
>gcloud config list
gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT DEFAULT_ZONE DEFAULT_REGION
default False youremail@gmail.com project-1 us-central1-a us-central1
test-config True youremail@gmail.com project-2 us-central1-f us-central1
9. Switch between configurations
gcloud config configurations activate CONFIGURATION_NAME
Now you can work under default configuration
>gcloud config configurations activate default
Activated [default].
10. Delete configuration
gcloud config configurations delete CONFIGURATION_NAME
>gcloud config configurations delete test-config
The following configurations will be deleted:
- test-config
Do you want to continue (Y/n)? Y
Deleted [test-config].