DevOps Peach

GCP Basics · Foundations – Regions, Resource Hierarchy, gcloud and Billing · Lesson 5 of 5

APIs, Quotas and Cloud Asset Inventory

Every service is an API you enable per project; quotas protect you and Google from runaway usage, and Cloud Asset Inventory searches and exports what exists across projects.

Practice interactively →

In Google Cloud each product is an API (for example compute.googleapis.com). An API must be enabled in a project before you can use it; enabling it may also create Google-managed service agents.

flowchart LR
  E["Enable compute.googleapis.com<br/>in dl-lab-dev"] --> Q["Quotas<br/>CPUs per region, requests per minute"]
  E --> R["Resources created"]
  R --> AI["Cloud Asset Inventory"]
  AI --> S["Search and export<br/>across the organization"]
  %% step E: Enable the API once per project; until then, calls fail with SERVICE_DISABLED. Enabling it may also create a Google-managed service agent.
  %% step Q: Quotas cap how much you can use, such as vCPUs per region or requests per minute.
  %% step R: Requests within quota create resources; over-quota requests fail with a 429 or QUOTA_EXCEEDED error.
  %% step AI: Cloud Asset Inventory keeps a history of resource metadata and IAM policies.
  %% step S: You can search, export to BigQuery or Cloud Storage, and watch changes with feeds.

Enabling APIs

gcloud services list --available --filter="name:run.googleapis.com"
gcloud services enable run.googleapis.com artifactregistry.googleapis.com
gcloud services list --enabled

Disabling an API can delete or break resources that depend on it, so treat gcloud services disable as a dangerous command.

Quotas

Type Example What happens when hit
Allocation (resource) quota 24 vCPUs (CPUS) in asia-southeast1 for a new project Creating more fails until you free resources or raise the quota
Rate quota API requests per minute per project Requests return HTTP 429 until the window resets

Cloud Asset Inventory

Cloud Asset Inventory keeps metadata about your resources and IAM policies for the last 35 days.

Feature Use
Search all resources “Find every VM with an external IP in the organization”
Search IAM policies “Who has roles/owner anywhere?”
Export Snapshot to BigQuery or Cloud Storage for audits
Feeds Pub/Sub messages when assets change
gcloud asset search-all-resources --scope=organizations/111122223333   --asset-types=compute.googleapis.com/Instance
gcloud asset search-all-iam-policies --scope=projects/dl-lab-prod --query="policy:roles/owner"

Gemini Cloud Assist

The console includes Gemini Cloud Assist, which can answer questions about your resources, help troubleshoot and suggest gcloud commands. Treat its suggestions like any other code: check them before you run them.

Command Meaning
gcloud services enable SERVICE Turn on an API in the current project
gcloud services list --enabled APIs that are on
gcloud compute regions describe asia-southeast1 Regional quotas and usage
gcloud asset search-all-resources --scope=… Search resources

Traps: “API not enabled” is a per-project error; quotas are per project and often per region; disabling an API can remove resources.

Practice interactively →