- Google Cloud SDK components and when to use them
- gcloud authentication and configuration best practices
- Example commands for common tasks
- Tips for automation and security
| Component | Purpose | Example command |
|---|---|---|
| gcloud | Primary CLI for managing Compute, Storage, Networking, IAM, Projects and other GCP services | gcloud compute instances create vm-1 |
| gsutil | Manage objects and buckets in Google Cloud Storage (GCS) — similar to AWS S3 tools | gsutil cp file.txt gs://my-bucket/ |
| bq | BigQuery command-line tool for running queries and managing datasets | bq query --use_legacy_sql=false 'SELECT COUNT(*) FROM mydataset.mytable' |
| kubectl | Kubernetes CLI for managing clusters (including GKE) and workloads. Often installed via gcloud or an OS package manager | kubectl get pods |

- Authenticate your user or service account
- Set the default project
- Optionally set default compute region/zone
- For interactive use, run:
- For headless or scripted environments:
- For service accounts (recommended for automation/CI):
- To obtain Application Default Credentials (for local code using Google client libraries):
Protect service account keys. Use Workload Identity (GKE) or short-lived credentials in CI when possible. Avoid committing
KEY.json into source control.- Set your active project so you don’t need
--projecton every command:
- Optionally set a default compute region or zone:
--zone, --machine-type, --tier) if defaults are not set or if the action needs them.
Configuration management and multi-project workflows
- Keep environments organized to avoid accidental deployments to the wrong project (dev, staging, prod).
- gcloud supports multiple named configurations that make switching contexts simple.
| Command | Purpose |
|---|---|
gcloud auth list | List authenticated accounts and show the active account |
gcloud config list | Show current configuration values (project, region, zone, etc.) |
gcloud config configurations list | List named configurations |
gcloud config configurations activate my-config | Activate a named configuration replacing my-config with your config name |
gcloud config set project <PROJECT_ID> | Set the active project for the current configuration |
Use the CLI for quick tasks, automation scripts, and CI/CD pipelines. For long-lived, reproducible infrastructure, combine gcloud with infrastructure-as-code tools like Terraform.
- Use gcloud for quick administration, ad-hoc scripting, or when you need direct control for a single project or operation.
- For repeatable, versioned infrastructure deployments across environments, prefer IaC tools (Terraform, Deployment Manager) and integrate gcloud commands into CI jobs when needed.
- For storage operations, use gsutil for bulk object transfers; for data warehouse operations, use
bqfor BigQuery tasks; for Kubernetes workloads, usekubectlor integrate withgcloud containercommands for GKE.
- gcloud CLI overview: https://cloud.google.com/sdk/gcloud
- Authentication for gcloud: https://cloud.google.com/sdk/docs/authorizing
- Configurations guide: https://cloud.google.com/sdk/docs/configurations
- gsutil documentation: https://cloud.google.com/storage/docs/gsutil
- BigQuery bq tool: https://cloud.google.com/bigquery/docs/bq-command-line-tool
- kubectl reference: https://kubernetes.io/docs/reference/kubectl/
