Skip to content

gcloud CLI

782 stars
official macOS Linux Cross-platform Actively maintained

The official Google Cloud CLI. Deploy services, manage infrastructure, query resources, and orchestrate GCP from any terminal with structured JSON output.

Part of the Google Cloud CLI tools for AI agents

What your agent can do

You need to deploy to Google Cloud. You open the GCP Console, navigate through three levels of menus, wait for the page to load, fill out the deployment form, click create, wait for the spinner. Your agent runs `gcloud run deploy my-service --image=gcr.io/project/app --region=us-central1 --format=json` and gets a deployment URL back in seconds.The `--format` flag is the most powerful output system of any CLI. `--format=json` for structured data. `--format=csv` for spreadsheet-ready output. `--format="value(name,status)"` for extracting specific fields without jq. `--format="table(name,zone,status)"` for human-readable tables. Your agent picks the format that matches the downstream consumer. No other cloud CLI offers this level of output control.Service account authentication makes gcloud fully headless. Your agent runs `gcloud auth activate-service-account --key-file=key.json` once, then every subsequent command authenticates automatically. No browser popups, no OAuth flows, no interactive prompts. Combined with `--project` and `--quiet` flags, every command is deterministic and scriptable.The `--filter` flag does server-side filtering before results hit your terminal. `gcloud compute instances list --filter="status=RUNNING AND zone:us-central1-*" --format=json` returns only running instances in a specific region. Your agent filters at the API level instead of fetching everything and parsing locally. Faster, cheaper, less bandwidth.The insider detail: `gcloud` is the underlying auth layer for Firebase CLI. When you run `firebase login`, it uses gcloud credentials. When you deploy Cloud Functions through Firebase, gcloud orchestrates it. Understanding this relationship means your agent can use whichever CLI fits the task: Firebase for app-level operations, gcloud for infrastructure.

Limitations

The CLI binary is proprietary Google software (not open-source). Large installation footprint (~500MB with all components). Some commands require additional components installed via `gcloud components install`. No official MCP server from Google yet, only community implementations. Authentication setup is more complex than single-token CLIs.

Key Commands

gcloud compute instances list List all Compute Engine VMs with details
gcloud run deploy Deploy a container to Cloud Run
gcloud functions deploy Deploy a Cloud Function
gcloud sql instances list List Cloud SQL database instances
gcloud container clusters list List GKE Kubernetes clusters
gcloud projects list List all projects in the account
gcloud auth activate-service-account Authenticate with a service account key for non-interactive use

GitHub Stats

repo GoogleCloudPlatform/cloud-sdk-docker
stars 782
language Python
license Apache-2.0
last commit Mar 24, 2026

FAQ

Is gcloud CLI free?
Yes. The gcloud CLI is free to download and use. You pay for GCP resources you provision, not the CLI tool. Install via `brew install google-cloud-sdk` on macOS or `apt-get install google-cloud-cli` on Linux. Service accounts are free to create for headless/agent authentication.
Can AI agents use gcloud CLI?
Yes. gcloud runs fully non-interactive with service account auth. Every command supports `--format=json` for structured output, `--filter` for server-side filtering, and `--quiet` to suppress prompts. Your agent authenticates once with `gcloud auth activate-service-account --key-file=key.json`, then has full access to all GCP services.
What is the difference between gcloud and AWS CLI?
gcloud manages Google Cloud. AWS CLI manages Amazon Web Services. Both support JSON output and non-interactive auth. gcloud's `--format` system is more flexible (json, csv, yaml, value, table, custom projections). AWS CLI's `--query` uses JMESPath for server-side filtering. Your agent uses whichever matches your cloud provider. Many teams use both for multi-cloud setups.
How do you use gcloud in CI/CD pipelines?
Set up a service account with minimal permissions. Store the key file as a CI secret. In your pipeline: `gcloud auth activate-service-account --key-file=$SA_KEY`, then run deployment commands with `--quiet` and `--format=json`. Works identically in GitHub Actions, GitLab CI, Cloud Build, and any CI provider.
What is the relationship between gcloud and Firebase CLI?
Firebase CLI uses gcloud under the hood for authentication and GCP resource management. Firebase is a product layer on top of Google Cloud. Your agent uses Firebase CLI for app-level operations (Firestore, Auth, Hosting) and gcloud for infrastructure (Compute, Cloud SQL, GKE, IAM). They share authentication — logging into one authenticates the other.

Last verified: Mar 25, 2026