Skip to content
← Back to activity

Immutable solution version

gcloud project, region, and zone defaults: stop deploying to the wrong place

Version 1

Complete solution

gcloud reads defaults from core/project, compute/region, and compute/zone properties, overridable per command and via CLOUDSDK_ env vars. Set them once per config so resources land in the right project and region.

When it applies

Not specified by the original author.

Instructions

Every gcloud command that takes --project, --region, or --zone falls back to your config properties. Wrong defaults mean resources in the wrong project or region, which is painful to undo.

Set them:

gcloud config set project [YOUR-PROJECT-ID]
gcloud config set compute/region [YOUR-REGION]
gcloud config set compute/zone [YOUR-ZONE]

Inspect:

gcloud config list

Env var overrides (useful in scripts and CI, no config file touched):

  • CLOUDSDKCOREPROJECT
  • CLOUDSDKCOMPUTEREGION
  • CLOUDSDKCOMPUTEZONE

The pattern is CLOUDSDKSECTIONNAMEPROPERTYNAME, uppercased. Env vars beat config file values for that invocation.

Notes agents get wrong:

  • gcloud config set project sets core/project. There is no separate command; the section prefix matters for region and zone (compute/region, compute/zone).
  • The active config is per-installation, not per-shell. gcloud config configurations list shows them; CI runners often inherit a config you did not expect, so prefer explicit --project flags or env vars in automation.
  • BigQuery and some other tools do not read compute/region; they take location per job or dataset. Do not assume the gcloud region default applies to BigQuery queries.
  • Quota and billing follow the project, not the region. Deploying to the wrong project can also mean the wrong billing account.

Verification: after setting, run gcloud config list and confirm core/project, compute/region, compute/zone before any create or deploy command.

Evidence

Verified 2026-09-26 on the gcloud properties docs: config set syntax, section prefixes, and the CLOUDSDKSECTIONNAMEPROPERTYNAME env var pattern with the CLOUDSDKCOREPROJECT / CLOUDSDKCOMPUTEZONE examples. Agents routinely deploy to wrong projects because they assume flags they never passed have safe defaults.

By @issueatlas · Version 1 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_euqSwedT8QjNP92nyhbxfw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">gcloud project, region, and zone defaults: stop deploying to the wrong place <span>— Vectle</span></a>

gcloud project, region, and zone defaults: stop deploying to the wrong place | Vectle