Prepare and test your skills
Prepare and test your skills
Enabling Google Cloud services means changing an API from disabled to enabled inside one Google Cloud project so applications in that project can consume it. The Service Usage API (opens in a new tab) is the control system that manages this lifecycle, and both the Google Cloud console and the gcloud command-line interface (CLI) send enable requests to it on behalf of the selected project. A project is the isolation boundary for quota and billing, so activation, limits, and charges are all tracked per project.
Identity and Access Management (IAM) roles for service management control who can turn services on and who can use the resources those services create. Activation requires the serviceusage.services.enable permission, which is included in the Owner role (roles/owner) and the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). The access flow runs from administrator to user to project: the administrator grants the role to the user on the IAM page, and the user then enables the service for that project.
Enabling a service does not grant permission to use it. After activation, the caller still needs service-specific roles, and user accounts and service accounts often need different roles because the user starts the work and the service account performs it. Common post-activation roles include:
Activation can also create broad access automatically. Enabling or first using a service that depends on Compute Engine creates the Compute Engine default service account (opens in a new tab) with the email format PROJECT_NUMBER-compute@developer.gserviceaccount.com. Depending on organization policy, that account may receive the Editor role on the project. Production workloads should follow least privilege by creating a dedicated service account, granting only minimum roles, and controlling the automatic grant with the iam.automaticIamGrantsForDefaultServiceAccounts organization policy constraint, enforced by default for organizations created after May 3, 2024.
Exam tip: Enabling an API does not grant permission to use it — serviceusage.services.enable only turns the service on, and Compute Engine, Pub/Sub, or Dataflow still require their own roles.
Quota management and billing requirements explain how an enabled service consumes limited capacity and how that use is paid for. Each Google Cloud project owns resources such as API keys, service accounts, virtual machines (VMs), Cloud Storage buckets, and BigQuery datasets, and usage telemetry is grouped by project. When an application calls an API, the project that owns the credentials is the client project and the project that owns the target resource is the resource project.
Current limits can be checked on the Quotas & System Limits page or on the APIs & Services page, where the Value column shows the default quota unless an adjustment was made. A quota adjustment changes that value up or down for a project and is subject to review. To adjust a quota in the console, follow this order:
A project needs an active billing account linked to it before chargeable APIs can be used. API usage is charged to the billing account linked to the project, so creating an account is not enough until it is linked. Disabling an API that is no longer used reduces misuse and accidental charges.
Service activation is the process that changes a Google Cloud API from disabled to enabled in a specific project after permission, project selection, and billing checks pass. Selecting an existing project requires only that the user already has a role on it, while creating a project requires Project Creator (roles/resourcemanager.projectCreator). Some APIs also require accepting Terms of Service or approval for preview access.
The two interactive activation methods send the same kind of request to the Service Usage API but fit different workflows:
| Method | How activation is sent | Choose when |
|---|---|---|
| Google Cloud Console | User opens an enable-flow link (opens in a new tab) for the selected project | A guided, one-click setup of multiple related APIs is needed |
| gcloud CLI | User runs gcloud services enable with full endpoint names such as compute.googleapis.com | A repeatable, scriptable setup or Cloud Shell workflow is needed |
API dependencies exist when one solution cannot run unless several related APIs are enabled together in the same project. Dataflow depends on Compute Engine for workers, Pub/Sub for ingestion, Cloud Storage for staging, BigQuery for output, Cloud Logging for logs, and Resource Manager for project metadata. Other common bundles include Cloud Deploy with Cloud Build, Google Kubernetes Engine (GKE), Cloud Run, and Cloud Storage, and Eventarc with Artifact Registry, Cloud Build, Logging, Pub/Sub, Cloud Run, Cloud Storage, and Eventarc itself. A typical gcloud workflow is ordered: first initialize and target the project, then verify billing and permissions, then enable the full service set in one command, and only after that set up authentication and workload roles.
Continue with this study guide: Enabling Google Cloud services
Making API calls to Google Cloud means choosing a communication interface and then optimizing how requests use the network and quotas. Each Cloud API runs as a network service on subdomains of googleapis.com, such as pubsub.googleapis.com, and accepts only secure requests using Transport Layer Security (TLS) encryption. Data flows from client applications to Google Cloud services across network boundaries, so efficient requests, good connectivity, and resilient error handling keep that flow fast and low cost.
API communication interfaces are the different ways application code reaches a Cloud API endpoint. The Cloud Client Libraries (opens in a new tab) are the recommended option where available because they provide idiomatic methods in the application's own language and handle authentication, low-level communication, and TLS encryption. Many Cloud Client Libraries use remote procedure call (RPC) efficiency under the hood while keeping a simple developer experience. They are available for Go, Java, Node.js, Python, Ruby, Rust, PHP, C#, and C++ and install through familiar package managers such as npm and pip.
Other interfaces reach the same backends with different trade-offs. RESTful interfaces are JSON over HTTP endpoints that every Cloud API exposes, where the application builds an HTTP request and receives a JSON response. An earlier generation, Google API Client Libraries, also accesses only this REST interface with auto-generated code that may be less idiomatic and never supports gRPC. gRPC is a language-neutral, open source remote procedure call system that sends compact binary protocol buffers (protobuf) over HTTP2 to the RPC interface, which reduces CPU work and increases throughput.
The documented trade-offs compare as follows:
| Option | Interface reached | Language and code fit |
|---|---|---|
| Cloud Client Libraries | REST, plus RPC under the hood for some APIs | Idiomatic, consistent style across supported languages |
| Google API Client Libraries | REST only, gRPC is not supported | Auto-generated and less idiomatic; use when Cloud Client Libraries are unavailable |
| Custom REST code | JSON over HTTP using a third-party HTTP client | Works wherever HTTP is available; developer manages versions, auth, and TLS |
| Custom gRPC code | Protobuf over HTTP2 to the RPC interface | Generated code from the API service definition; up to 10x throughput per CPU versus JSON REST |
Google APIs Explorer is a no-code browser tool for trying live APIs without writing code. Trial traffic flows from the Explorer to the live API endpoint, and the Explorer shows the request structure and response. Developers use it to confirm endpoints, required fields, and response shape before implementing the same call in a client library or custom client.
Exam tip: All Cloud APIs expose a JSON/REST interface, but only gRPC-enabled APIs expose an RPC interface; Google API Client Libraries support REST only, never gRPC.
Optimization of data transfer and resource utilization reduces network overhead, latency, and quota use while provisioning only needed capacity. Each HTTP request carries connection setup, authentication, and header costs, so batching multiple smaller calls into fewer larger calls lowers latency and consumes less rate quota. Batching is most valuable for non-urgent, repetitive work such as creating, updating, or fetching many similar resources, and the same idea applies to compute work grouped on Batch or Dataflow.
Restricting return data and paginating results keep individual responses small and predictable. Restricting return data means asking for only essential attributes, often with field masks, so a smaller response travels faster and lowers egress and processing cost. Pagination returns large datasets in pages controlled by tokens: the client requests one page, receives data plus a token for the next page, and requests the next page only if needed. Token-based pagination avoids timeouts and keeps memory use predictable.
Connectivity and scaling choices further control latency and cost. Cloud Interconnect provides private connectivity with production-level availability, while Cross-Cloud Interconnect connects another cloud and CDN Interconnect optimizes large transfers to supported third-party content delivery networks (CDNs). To minimize latency, traffic should flow to a Google Cloud region close to the backend or frequent caller, with correct maximum transmission unit (MTU), DNS, and route settings. Autoscaling then matches capacity to load: Compute Engine managed instance groups scale stateless VMs, GKE resizes node pools, Cloud Run scales containers to zero when idle, and Bigtable adjusts nodes to maintain target utilization.
Resilience and performance through error handling and caching keep applications responsive when dependencies fail while avoiding repeated work. Resilient service communication prevents a slow backend from overloading its callers, sometimes called a cascading failure. Three related patterns protect service-to-service calls: circuit breaker stops sending requests to a failing service for a period, exponential backoff retries a failed request after increasingly longer waits to spread load, and graceful degradation returns a limited but useful response when a dependency is unavailable.
Caching stores reusable answers close to the requester so later requests do not travel all the way to the backend. Data flows from the backend service to the cache on the first request, then from the cache to the frontend or client on later identical requests. Different caches serve different layers:
Efficient fetching and health-aware routing reduce the failing calls that error handling must absorb. Apps can send fewer requests, retrieve information in parallel, and preload assets. Cloud Load Balancing distributes traffic so individual resources do not overload while others sit idle: traffic flows from clients to the load balancer, and the load balancer forwards it only to backends with available capacity. Health checks ensure traffic flows only to responsive backends, so if application software crashes while VMs remain in the RUNNING state, new requests flow to healthy backends instead.
Using service accounts to make Cloud API calls means running application code under a managed machine identity that authenticates to Google Cloud APIs. A service account (opens in a new tab) is the identity an application uses to call APIs, and its access is limited by IAM roles plus access scopes on the compute resource. Both configurations must allow access before OAuth requests from the gcloud CLI and client libraries can reach the resource.
IAM roles and access scopes are two filters that together control what a service account on a Compute Engine VM can access. An IAM role is set on the service account for a project or resource and defines which APIs and resources that account can access. An access scope is set on the VM instance for its lifetime and defines which default OAuth 2.0 scopes the gcloud CLI and client libraries on that instance can request. Scopes have no effect unless the related API is enabled, and scopes do not apply to calls made using gRPC.
The comparison shows where each control lives and what it does:
| Control | Where it is set | What it controls |
|---|---|---|
| IAM role | On the service account for a project or resource | Which APIs and resources the service account and its apps can access |
| Access scope | On the VM instance for its lifetime | Which default OAuth scopes the gcloud CLI and client libraries can request from that VM |
The best practice is to set the full cloud-platform scope (https://www.googleapis.com/auth/cloud-platform) on the VM and then enforce least privilege with fine-grained IAM roles. For example, a VM with the broad cloud-platform scope plus roles/storage.objectViewer can only read objects. In contrast, a VM with the narrow devstorage.read_only scope plus the broad roles/storage.objectAdmin role still cannot manage objects from client libraries, because the read-only scope does not authorize writes. New instances also receive default scopes for read-only Storage, log writes, metric writes, Service Management, Service Control, and Trace, but production code should use dedicated single-purpose service accounts and avoid basic Owner, Editor, or Viewer roles.
Exam tip: A narrow access scope can block an API call even when the IAM role allows it, so use the cloud-platform scope and control access with fine-grained IAM roles.
Secure credential management is the choice between short-lived credentials obtained on demand and long-lived keys stored as files. Short-lived credentials expire by default after 1 hour and are minted by Google, while user-managed service account keys (opens in a new tab) remain valid until deleted and must be protected by the holder. Each service account can have up to 10 user-managed keys, and anyone holding a private key can authenticate as that account without extra checks like 2-step verification.
Google-owned keys versus user-managed keys differ in who holds the private key. Google-owned pairs are held in escrow and never exposed, and Google uses them to mint short-lived OAuth 2.0 access tokens, OpenID Connect (OIDC) ID tokens, self-signed JSON Web Tokens (JWTs), or blobs through the Service Account Credentials API. User-managed pairs store only the public portion at Google while the holder stores the private key file, so the file must never remain in temporary directories, email, file shares, backups, repositories, or binaries.
Service account impersonation avoids distributing keys by letting a source principal with the Service Account Token Creator role mint short-lived credentials for a target account. Traffic flows from the source principal to the Service Account Credentials API, then the minted token flows to the destination API under the target identity. Common flows include the gcloud CLI with --impersonate-service-account, external workloads using workload identity federation with a credential configuration file, and services minting temporary credentials for users. Self-impersonation is blocked: a short-lived credential cannot create another access token for the same account or sign blobs for IAM and token APIs, returning FAILED_PRECONDITION, except that a self-signed JWT can still obtain a token for the same account. When keys cannot be avoided, reduce risk with rotation, expiry for temporary use, organization policy guardrails such as automatic disabling of leaked keys, and detection of unused keys.
Application Default Credentials (ADC) is a standard credential-discovery strategy that lets the same code run locally and on Google Cloud. ADC is used by Google authentication libraries to automatically find credentials based on the environment and make them available to Cloud Client Libraries and Google API Client Libraries. When an application uses ADC, the same authentication code can run in development and production without changing how it authenticates.
ADC discovers credentials in a fixed search order and uses the first credentials it finds:
gcloud auth application-default login.The environment-variable file can be a Workforce Identity Federation configuration, a Workload Identity Federation configuration, or a service account key, with keys not recommended. The local login file lives at $HOME/.config/gcloud/application_default_credentials.json on Linux and macOS and %APPDATA%\gcloud\application_default_credentials.json on Windows, and by default includes the cloud-wide https://www.googleapis.com/auth/cloud-platform scope. Production ADC depends on the attached service account: traffic flows from the application to the metadata server, and the metadata server returns short-lived credentials for that account. Setup is ordered — first create a dedicated least-privilege service account, then grant only needed roles, then attach it to the resource before code needs it. Most services require attachment at creation time, while Compute Engine allows attaching a service account to a VM at any time.
Continue with this study guide: Using service accounts to make Cloud API calls
serviceusage.services.enable permission through Owner or Service Usage Admin, and using the service afterward still requires its own service-specific IAM roles.GOOGLE_APPLICATION_CREDENTIALS file first, then the local file from gcloud auth application-default login, then the attached service account from the metadata server.Enabling a Google Cloud API requires the serviceusage.services.enable permission, which is included in the Owner role and the Service Usage Admin role. Enabling only changes the API from disabled to enabled in the project and does not grant permission to use it, so the caller still needs the service-specific roles afterward.
Cloud Client Libraries are the recommended option where available because they provide idiomatic methods in the application language and handle authentication and Transport Layer Security encryption. Custom gRPC code sends compact binary protocol buffers over HTTP2 to the remote procedure call interface and can increase throughput per CPU by up to 10x versus JSON REST, while requiring generated code from the API service definition.
Application Default Credentials discovers credentials in a fixed search order and uses the first credentials it finds. It checks the credential file at the path in the GOOGLE_APPLICATION_CREDENTIALS environment variable first, then the local file created by gcloud auth application-default login, then the service account attached to the Google Cloud resource from the metadata server.
Last updated