A developer environment for Google Cloud has to satisfy three overlapping demands:
- it must run business code against managed services without burning real quota during the inner loop,
- it must give every engineer an identical baseline so that "works on my machine" stops being a triage step,
- it must let an AI coding assistant read your source tree without exposing secrets or rebuilding context every time you open a file.
The Cloud SDK, Cloud Code, Cloud Shell, Cloud Workstations, Gemini Cloud Assist, and MCP integrations form a layered answer to that demand. The choice of which layer to use for a given task is itself examinable, because each tool publishes different SLAs, billing surfaces, and IAM scopes.
How it works
Before discussing the tools, internalise the principle that drives most of the trade-offs in this section. Unit tests should never call a production Google Cloud API. Integration tests may, but only against a project carved out for testing with quota budgets and an isolated billing account. The gcloud-CLI-managed emulators are the line between the two: anything that runs against the emulator is a unit test, anything that hits a real endpoint is an integration test. This split shows up directly in Cloud Build pipelines later in the chapter, where the unit step starts an emulator sidecar and the integration step does not.
The cost model is the second principle.
- Cloud Workstations is billed per running configuration plus the underlying Compute Engine resources, so leaving an idle workstation running for hours is a real spend.
- Cloud Shell is free up to its weekly hour quota and gives every Google Cloud user a 5 GB persistent
$HOME. - Local development against the gcloud CLI emulators costs nothing beyond the developer's laptop.
A correct answer on an exam question about cost normally pushes the work to the cheapest tier that meets the latency and isolation requirements.
📊 Limit: Cloud Shell provides 5 GB of persistent
$HOMEstorage per user, automatically reclaimed after 120 days of inactivity, and 50 hours of weekly usage. Plan around those quotas before recommending Cloud Shell as a primary developer surface for a team.
The third principle is identity hygiene.
The Cloud SDK resolves credentials through Application Default Credentials, which look first at the GOOGLE_APPLICATION_CREDENTIALS environment variable, then at user credentials stored by gcloud auth application-default login, and finally at the attached service account when the workload runs on Compute Engine, GKE, Cloud Run, or Cloud Functions.
Avoiding JSON key files in every layer of the environment is not optional.
On Cloud Workstations, the attached workstation service account already returns short-lived tokens through the metadata server, and on Cloud Shell the active user's OAuth token is automatically available.
AI assistants and MCP servers must consume those same tokens rather than asking the developer to paste a key.
Emulating Google Cloud services for local development and unit testing
The Cloud SDK ships in-process emulators for Pub/Sub, Spanner, Bigtable, Firestore, and the Datastore mode of Firestore, plus a separate Functions Framework that runs Cloud Run functions locally.
Each emulator is started as a sub-process of the gcloud CLI, exposes a localhost endpoint, and exports the environment variables that Cloud Client Libraries read to redirect API calls.
The emulator never speaks to a real Google Cloud project, so it does not validate IAM, does not enforce quotas, and does not check resource locations; that limitation is itself an exam topic. The first thing to install is the emulator component.
Components are added through gcloud components install; the manager refuses to install if the SDK was installed through a package manager like apt, in which case the emulator binaries come from a sibling package such as google-cloud-cli-pubsub-emulator.
The following session shows the installation followed by a Pub/Sub emulator launch with port pinning and message retention disabled for deterministic tests.
gcloud components install pubsub-emulator beta
gcloud components install cloud-firestore-emulator
gcloud components install cloud-spanner-emulator
gcloud components install bigtable-emulator
# Start Pub/Sub on a fixed port so the test harness can connect deterministically
gcloud beta emulators pubsub start \
--host-port=localhost:8085 \
--project=pcd-local-tests &
# Export the env vars Cloud Client Libraries look for
$(gcloud beta emulators pubsub env-init)
# Confirm the override took effect
echo "PUBSUB_EMULATOR_HOST=${PUBSUB_EMULATOR_HOST}"
The pattern is identical for the other emulators: install the component, run gcloud beta emulators <service> start, then evaluate env-init so the environment variables PUBSUB_EMULATOR_HOST, FIRESTORE_EMULATOR_HOST, SPANNER_EMULATOR_HOST, BIGTABLE_EMULATOR_HOST, and DATASTORE_EMULATOR_HOST are exported into the calling shell. The Cloud Client Libraries in Go, Java, Node.js, and Python all read these variables and skip the OAuth handshake when they find one, which is why no service account key is needed for unit tests.
A common unit test fixture in Python looks like this. The fixture starts the emulator before the test session, creates a topic and a pull subscription, and tears the emulator down at the end.
import os
import subprocess
import time
import pytest
from google.api_core import retry
from google.cloud import pubsub_v1
PROJECT_ID = "pcd-local-tests"
TOPIC_ID = "orders"
SUB_ID = "orders-worker"
@pytest.fixture(scope="session", autouse=True)
def pubsub_emulator():
proc = subprocess.Popen(
["gcloud", "beta", "emulators", "pubsub", "start",
"--host-port=localhost:8085", f"--project={PROJECT_ID}"]
)
os.environ["PUBSUB_EMULATOR_HOST"] = "localhost:8085"
time.sleep(2) # wait for the gRPC listener to bind
publisher = pubsub_v1.PublisherClient()
subscriber = pubsub_v1.SubscriberClient()
topic_path = publisher.topic_path(PROJECT_ID, TOPIC_ID)
sub_path = subscriber.subscription_path(PROJECT_ID, SUB_ID)
publisher.create_topic(name=topic_path)
subscriber.create_subscription(name=sub_path, topic=topic_path)
yield
proc.terminate()
proc.wait()
def test_publish_and_pull():
publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(PROJECT_ID, TOPIC_ID)
future = publisher.publish(topic_path, b"hello")
future.result(timeout=5)
subscriber = pubsub_v1.SubscriberClient()
response = subscriber.pull(
request={"subscription": subscriber.subscription_path(PROJECT_ID, SUB_ID),
"max_messages": 1},
retry=retry.Retry(deadline=10),
)
assert len(response.received_messages) == 1
assert response.received_messages[0].message.data == b"hello"
Comparison
The Cloud Spanner emulator runs as a Docker container in addition to the gcloud CLI route, and listens on a gRPC port plus a separate REST port. The Bigtable emulator follows the same pattern.
Firestore's emulator includes a UI tab in the local emulator suite that the firebase CLI offers, but the gcloud emulator surface ships only the gRPC endpoint.
The Spanner emulator does not support every SQL feature of the production service, in particular some statistics and views, so an integration suite still needs a real Spanner instance for parity tests.
💡 Exam Trap: The emulators do not enforce IAM permissions, quota, or organisation policies. A unit test that creates a Cloud Storage bucket against the emulator equivalent will succeed even when the deployer's service account would fail in production. The exam frames this as a security regression: passing unit tests do not imply the workload has the IAM bindings it needs at runtime.
⚠️ Anti-Pattern: Running unit tests against a real Google Cloud project named something like
dev-personalto "save time setting up the emulator." The cost adds up across CI runs, the data plane becomes a leak surface, and any quota exhaustion immediately stalls the engineer's own ad hoc work. The emulator endpoint is the right answer; if a feature is not emulated, the test belongs in the integration suite, not the unit suite.
📊 Limit: The Spanner emulator supports a single instance and a single database per emulator process, and does not implement backup, restore, change streams, or per-region replica configuration. Tests that depend on those features must run against a real Spanner instance in a test project.
Using developer tooling: Console, Cloud SDK, Cloud Code, Gemini Cloud Assist, Cloud Shell, Cloud Workstations
The Cloud SDK is the foundation.
It bundles gcloud, bq, gsutil (superseded by gcloud storage), kubectl plug-in glue, the gke-gcloud-auth-plugin, and the emulators above.
Cloud SDK configurations split environments:
- each named configuration carries its own
core/project,compute/region,compute/zone, and auth account - so
gcloud config configurations activate devswitches the entire context with one command.
A team should publish a script that creates the same set of configurations on every developer's machine so commands never target the wrong project by accident.
# One-time bootstrap per developer
gcloud config configurations create dev
gcloud config set core/project pcd-dev-001
gcloud config set compute/region us-central1
gcloud auth login alice@example.com
gcloud config configurations create stg
gcloud config set core/project pcd-stg-001
gcloud config set compute/region europe-west1
gcloud config configurations create prod
gcloud config set core/project pcd-prod-001
gcloud config set compute/region us-central1
gcloud config configurations list
gcloud config configurations activate dev
Cloud Code is the IDE extension family for VS Code and JetBrains. It surfaces:
- Cloud Run service deploys
- GKE cluster browsing
- Cloud Storage object access
- Secret Manager secret reads
- Skaffold-based local development loops
- Cloud Build triggers without leaving the editor
Cloud Code provides a "Run on Cloud Run Emulator" command that builds a container locally and runs it inside a containerised Cloud Run shim so request lifecycle and PORT semantics match production.
The same extension reads a skaffold.yaml to keep file watchers, automatic rebuilds, and port-forwarded GKE workloads in sync.
# skaffold.yaml for an iterative Cloud Run local loop
apiVersion: skaffold/v4beta11
kind: Config
metadata:
name: order-service
build:
artifacts:
- image: us-central1-docker.pkg.dev/pcd-dev-001/services/order-service
jib:
type: gradle
project: order-service
tagPolicy:
gitCommit: {}
deploy:
cloudrun:
projectid: pcd-dev-001
region: us-central1
profiles:
- name: gke-dev
deploy:
kubectl:
manifests:
- k8s/order-service.yaml
Cloud Shell gives a Debian shell on a managed VM with the Cloud SDK, kubectl, Skaffold, Terraform, and the editor preinstalled.
Cloud Shell sessions are stateless except for the 5 GB persistent $HOME, and they inherit the active user's OAuth token through the metadata server, so commands do not require a separate gcloud auth step.
Cloud Shell is the right tool for:
- a one-off bucket creation,
- a quick IAM binding fix,
- running a CLI command that the engineer does not want to install locally.
It is not the right tool for sustained development: the VM resizes on reconnect, the network egress charges to the user's project, and there is no GPU surface.
In practice
Cloud Workstations is the long-lived counterpart.
A workstation cluster lives in a VPC, runs node pools in chosen regions, and serves browser-based and SSH access to per-developer workstations launched from a workstation configuration.
The configuration pins the container image (typically a Google-maintained codeoss image or a custom image hosted in Artifact Registry), the machine type, idle and running timeouts, persistent disk, and IAM roles.
Because the workstation runs inside the customer VPC, it can reach private GKE control planes and Private Service Connect endpoints without traversing the public internet.
The configuration also lets the platform team mandate that workstations run with a dedicated service account, so the developer's user token never decorates the workload.
# Create a workstation cluster, configuration, and workstation
gcloud workstations clusters create pcd-cluster \
--region=us-central1 \
--network=projects/pcd-dev-001/global/networks/dev-vpc \
--subnetwork=projects/pcd-dev-001/regions/us-central1/subnetworks/dev-subnet
gcloud workstations configs create pcd-codeoss \
--cluster=pcd-cluster --region=us-central1 \
--machine-type=e2-standard-4 \
--container-predefined-image=codeoss \
--idle-timeout=3600s \
--running-timeout=43200s \
--service-account=workstation-dev@pcd-dev-001.iam.gserviceaccount.com \
--pd-disk-size=100 \
--pd-disk-type=pd-balanced
gcloud workstations create alice-ws \
--cluster=pcd-cluster --config=pcd-codeoss --region=us-central1
Key points
Gemini Cloud Assist is the conversational layer in the Cloud Console; it answers questions about resources in the current project, drafts gcloud commands, summarises Cloud Logging error volumes, and explains diagnostic findings.
Gemini Code Assist is the equivalent surface inside the IDE; the two services are siblings rather than the same product.
Both run on Gemini foundation models in Vertex AI, both honour the project-level data residency setting, and both reuse the active user's identity for authorisation.
💡 Exam Trap: Cloud Shell and Cloud Workstations are not interchangeable. Cloud Shell is ephemeral, shared-tenant, and free up to its quota; Cloud Workstations is persistent, VPC-attached, billed per running workstation, and the only one that can reach private clusters without a Cloud VPN tunnel. Picking Cloud Shell for a regulated team that needs VPC-attached development time fails an exam item.
🎯 Scenario: A platform team wants every backend engineer to land on an identical environment with
gcloud,kubectl, Skaffold, and Cloud Code preinstalled, reach a private GKE Autopilot cluster, and never store service account keys on local disks. The fit is Cloud Workstations with a customcodeossimage stored in Artifact Registry, a workstation configuration that pins the workstation service account and the VPC subnet, and Workload Identity Federation for any external API access. Cloud Shell, while convenient, cannot reach the private cluster without a separate authorised network or tunnel.
Configuring IDEs with the Cloud SDK, AI coding assistants, and MCP integrations
An IDE on Google Cloud is a stack of three layers:
- The Cloud SDK that translates editor actions into authenticated API calls.
- The AI coding assistant that generates code and explanations next to the cursor.
- The Model Context Protocol servers that let the assistant call additional tools or read additional sources of context such as a database schema, a documentation site, or an internal ticketing system.
Misconfiguring any layer creates either a security hole or a poor developer loop. The Cloud SDK layer requires Application Default Credentials.
On a developer laptop, that means running gcloud auth application-default login once; on Cloud Workstations and Cloud Shell, the metadata server already returns short-lived tokens for the workstation or shell service account, and gcloud auth application-default login is unnecessary.
Setting GOOGLE_APPLICATION_CREDENTIALS to a JSON key file is technically supported but is the path the exam treats as a fallback for legacy workloads, not a recommendation.
# Developer laptop, one-time
gcloud auth application-default login
gcloud auth application-default set-quota-project pcd-dev-001
# Optional: configure impersonation so the developer acts as a service account
# without ever holding a key
gcloud config set auth/impersonate_service_account \
builder@pcd-dev-001.iam.gserviceaccount.com
Cloud Code wires itself to ADC automatically; the extension picks up the same configuration the gcloud CLI uses.
Gemini Code Assist authenticates through the developer's Google account and reads the editor workspace through file system access, never sending source to third parties; Code Assist runs as a managed service that talks to Gemini models in Vertex AI on the user's behalf.
Code Assist supports:
- inline completion
- chat-based code generation
- code transformation
- explain-this-code workflows
The IDE extension applies the project-level "AI access controls" set on the Cloud account, so an admin can disable any of those features for sensitive repositories.
Model Context Protocol is an open JSON-RPC-over-stdio protocol for letting an AI assistant call external tools with structured arguments and read structured resources.
An MCP server publishes a set of tool definitions; the IDE extension exposes those tools to the assistant; the assistant decides which tool to call based on the conversation. Google publishes:
- a Cloud Run MCP server for managing Cloud Run services
- an Apigee MCP server for managing Apigee APIs
- an AlloyDB MCP server for browsing AlloyDB schemas without leaving the editor
Third-party MCP servers exist for GitHub, Jira, Sentry, and many other tools; the developer wires them into the IDE through a configuration file.
A typical VS Code MCP configuration looks like this. Note that the env block pulls the service account from Cloud KMS-protected Secret Manager rather than embedding a key in the file.
{
"mcpServers": {
"cloud-run": {
"command": "npx",
"args": ["-y", "@google-cloud/cloud-run-mcp"],
"env": {
"GOOGLE_CLOUD_PROJECT": "pcd-dev-001",
"GOOGLE_CLOUD_REGION": "us-central1"
}
},
"alloydb": {
"command": "uvx",
"args": ["alloydb-mcp", "--instance",
"projects/pcd-dev-001/locations/us-central1/clusters/orders-c/instances/orders-primary"],
"env": {
"AUTH_MODE": "ADC"
}
},
"github": {
"command": "docker",
"args": ["run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${secret:projects/pcd-dev-001/secrets/gh-pat/versions/latest}"
}
}
}
}
The flow when an MCP server is wired in is shown below. The assistant asks the IDE which tools are available, the IDE forwards the schema from the MCP server, and the assistant generates a tool call rather than free-form text when the conversation indicates a side effect is required.
💡 Exam Trap: MCP servers run with the credentials of the developer's IDE process, which by default is the Application Default Credentials chain. Granting a developer the ability to wire an MCP server to a privileged service account via impersonation can expand the developer's effective permissions without changing their direct IAM bindings. Tightly scope
iam.serviceAccounts.actAsto the workstation service account, never the developer's user account, for production-facing MCP integrations.
⚠️ Anti-Pattern: Embedding long-lived OAuth refresh tokens or service account JSON keys directly into an MCP configuration file checked into source control. The right pattern is to reference Secret Manager versions or use ADC plus impersonation. A single keystroke can otherwise push a key to a public repository.
📊 Limit: Gemini Code Assist standard tier permits unlimited chat usage but caps code transformation actions per user per calendar period under fair-use guidance; verify the active tier on the official Code Assist documentation page before sizing a rollout.
This section's decision anchor:
- Choose Cloud Workstations when a team needs identical, VPC-attached, persistent development environments with strict identity controls.
- Choose Cloud Shell when a single user needs a transient shell to run an ad hoc command.
- Choose pure local development with the Cloud SDK and emulators when the inner loop runs entirely offline and the developer's laptop is governed by an existing endpoint management policy.
Pick the cheapest tier that satisfies the latency, isolation, and IAM requirements. ---
