| name | gcloud-cli |
| description | Execute Google Cloud Platform operations using the gcloud CLI (and gsutil/bq where applicable). Use when the user wants to: authenticate with GCP, manage GCP resources, deploy applications, configure projects or IAM, view logs, run SQL/BigQuery, or interact with any GCP service from the command line. Triggers on phrases like "gcloud", "Google Cloud CLI", "deploy to GCP", "create a VM", "Cloud Run", "GKE cluster", "Cloud Storage bucket", "set GCP project", "service account", "Cloud Functions", "App Engine deploy", or any request to manage Google Cloud resources via command line.
|
gcloud CLI
Command Structure
gcloud [GROUP] [SUB-GROUP] COMMAND [FLAGS]
Examples:
gcloud compute instances list
gcloud run services deploy my-svc --image gcr.io/my-project/my-image
gcloud projects list
Configuration
gcloud init
gcloud config set project PROJECT_ID
gcloud config set compute/region us-central1
gcloud config set compute/zone us-central1-a
gcloud config list
gcloud config configurations create staging
gcloud config configurations activate staging
Authentication
gcloud auth login
gcloud auth application-default login
gcloud auth activate-service-account SA_EMAIL --key-file=key.json
gcloud [COMMAND] --impersonate-service-account=SA_EMAIL
gcloud auth list
Output Formatting
--format=json
--format=yaml
--format=table(col1,col2)
--format="value(name)"
--filter="status=RUNNING"
--filter="name ~ '^prod-'"
--sort-by=createTime
--limit=10
Useful Global Flags
| Flag | Purpose |
|---|
--project=PROJECT_ID | Override active project |
--region=REGION | Override default region |
--zone=ZONE | Override default zone |
--quiet / -q | Skip confirmation prompts |
--verbosity=debug | Debug output |
--dry-run | Preview without executing (where supported) |
Service Commands Reference
For service-specific commands (Compute Engine, Cloud Run, GKE, Cloud Storage, IAM, App Engine, Cloud Functions, Cloud SQL, BigQuery, Pub/Sub, Artifact Registry), see references/services.md.
Common Patterns
Get resource details
gcloud RESOURCE describe RESOURCE_NAME [--region/--zone]
Wait for long-running operations
gcloud compute operations wait OPERATION_ID
Use --format=value() in scripts
PROJECT=$(gcloud config get-value project)
IMAGE_DIGEST=$(gcloud container images describe gcr.io/$PROJECT/app:latest --format="value(image_summary.digest)")
IAM policy binding pattern
gcloud RESOURCE add-iam-policy-binding RESOURCE_ID \
--member="serviceAccount:SA@PROJECT.iam.gserviceaccount.com" \
--role="roles/ROLE"