$ command-helper

Google Cloud CLI (gcloud)

Accounts and projects, Compute Engine, GKE credentials, Cloud Storage, logs and secrets.

Requires Google sign-in

Auth and projects

Log in
gcloud auth login
Credentials for local apps and Terraform (ADC)
gcloud auth application-default login
Current account and project
gcloud config list
Switch project
gcloud config set project <gcp_project>
Named configurations for several projectsadvanced
gcloud config configurations create <gcp_config> && gcloud config configurations activate <gcp_config>

Compute Engine

List VMs
gcloud compute instances list
SSH into a VM
gcloud compute ssh <gce_instance> --zone <gcp_zone>
SSH through IAP without a public IPadvanced
gcloud compute ssh <gce_instance> --zone <gcp_zone> --tunnel-through-iap
Stop or start a VM
gcloud compute instances stop <gce_instance> --zone <gcp_zone>

GKE

List clusters
gcloud container clusters list
Get kubectl credentials for a cluster
gcloud container clusters get-credentials <gke_cluster> --region <gcp_region>

Storage, logs, secrets

List buckets and objects
gcloud storage ls gs://<gcs_bucket>/
Copy files to or from a bucket
gcloud storage cp -r ./dist gs://<gcs_bucket>/
Read recent error logs
gcloud logging read 'severity>=ERROR' --limit 20 --freshness 1h
Read a secret
gcloud secrets versions access latest --secret <gcp_secret>
Which APIs are enabledadvanced
gcloud services list --enabled
Who has which role in the projectadvanced
gcloud projects get-iam-policy <gcp_project> --flatten='bindings[].members' --format='table(bindings.role, bindings.members)'