Brains4Cloud
ESEN
Practice

Topic 4 of 5

D1 · Setting up a cloud solution environment

Cloud Asset Inventory and Gemini Cloud Assist

Once an organization has hundreds of projects, the question "what do we have and who can access it?" can't be answered by hand anymore. The exam guide asks for "Configuring Cloud Asset Inventory and using Gemini Cloud Assist to analyze resources": the first keeps the metadata inventory, and the second is the AI assistant that helps you design, operate, and optimize.

A global metadata inventory to view, search, export, monitor, and analyze Google Cloud assets. It is designed for compliance tracking, scheduled audits, and analytics.

Resource discovery

Filter by location, creation time, tags, or status.

Resource monitoring

Track how a resource changes over time to audit, debug, and catch compliance drift.

Security and cost audits

Find resources that are over-permissioned, publicly exposed, or unused.

  • It keeps create, update, and delete history for 35 days. Assets with no changes in that time return their latest status.
  • Metadata comes from resources (VMs, buckets, App Engine instances…), from policies (IAM, organization, Access Context Manager), and from OS inventory management runtime information.
  • It also lets you analyze what would happen if a resource moved to another project and view effective IAM policies: who has access to what.

Not for real time

Google warns that it isn't designed for real-time queries where stale data could break availability or security enforcement. For that, call the service's API directly.

Content types

When you query, you specify which metadata you want. Without a content type you get only the basics: asset name, last update, and its ancestors (project, folders, organization).

API (gcloud)What it returns
RESOURCE (resource)All of the resource's metadata
IAM_POLICY (iam-policy)The resource's IAM policy bindings
ORG_POLICY (org-policy)Organization policies (v1); for v2 use RESOURCE with the orgpolicy.googleapis.com/Policy type
ACCESS_POLICY (access-policy)Access Context Manager policies
OS_INVENTORY (os-inventory)VM operating system inventory. Requires setting up VM Manager
RELATIONSHIP (relationship)Relationships between resources (e.g. a VM uses a disk). Requires Security Command Center Premium or Enterprise, or Gemini Cloud Assist

Setting it up: API and roles

1

Enable the Cloud Asset Inventory API. In the project you run the commands from (cloudasset.googleapis.com).

2

Grant the right role. Cloud Asset Viewer (roles/cloudasset.viewer) to read the inventory on the project, folder, or organization.

3

Prepare the destination. A BigQuery dataset or bucket for exports, or a Pub/Sub topic for feeds.

Listing and searching resources and policies

In the console, the Asset Inventory page has a Resource tab where you filter with the search syntax, see the equivalent gcloud query (View query), and download the results as CSV.

# List a project's Compute Engine assets
gcloud asset list --project=PROJECT_ID --asset-types=compute.googleapis.com/Instance

# Search resources in an organization
gcloud asset search-all-resources --scope=organizations/ORG_ID --query="location:us-central1"

# Search IAM policies that grant public access
gcloud asset search-all-iam-policies --scope=organizations/ORG_ID \
  --query="memberTypes:(allUsers OR allAuthenticatedUsers)" --format="table(resource)"
  • Searches are synchronous and consume quota; for large inventories, use asynchronous methods such as export.
  • Not every resource type is searchable: the resource types documentation shows which ones the search APIs support.
  • A tip from the docs: run a search with no query first and use the fields in the response to build your filter.

Exporting to BigQuery or Cloud Storage

An export takes a snapshot of the organization, folder, or project (it can be from a past date, up to 35 days back) to analyze with SQL in BigQuery or store in Cloud Storage.

gcloud asset export --project=my-project --content-type=resource \
  --snapshot-time="2024-01-30" \
  --bigquery-table=projects/my-project/datasets/my-dataset/tables/my-table
  • With --per-asset-type you get one table per asset type, with columns for the nested fields.
  • You can't append to an existing table unless it is partitioned: the table must be empty or overwritten with --output-bigquery-force.
  • Clustered tables aren't supported, and some frequently changing fields, such as numRows, may be exported as null.

Feeds: real-time change notifications

A feed sends a notification to a Pub/Sub topic whenever the resources, IAM policies, access policies, or organization policies you choose change in an organization, folder, or project. You can add conditions so you only get certain kinds of changes.

gcloud asset feeds create my-feed --project=my-project \
  --pubsub-topic=projects/my-project/topics/my-topic \
  --asset-names=//storage.googleapis.com/my-bucket --content-type=iam-policy
  • The first message is a welcome message; the rest are TemporalAsset objects with the new state and the previous one (priorAsset).
  • Google suggests connecting notifications to your workloads, for example a Cloud Run function that reverts an unauthorized change.

An AI collaborator built into Google Cloud that helps you design, deploy, troubleshoot, and optimize workloads. Google describes it as a multi-agent ecosystem with reasoning, tool calls, and long-term memory.

It uses as context your project and organization IDs, the console page you are viewing (URL and visible text), and session memory. Several of its features are in preview. Like any generative AI, it can produce plausible but incorrect output: Google recommends validating everything it generates.

Setting up Gemini Cloud Assist

An administrator sets it up for a project or folder before the team can use it.

1

Admin for Gemini → Get Gemini Cloud Assist. Pick the recommended APIs and click Enable Gemini Cloud Assist at no cost.

2

Grant roles to each principal. Gemini Cloud Assist User and Cloud Asset Viewer, plus roles for the products they want help with.

3

Optional settings. Share prompts to improve the product, custom instructions, grounding.

gcloud services enable geminicloudassist.googleapis.com --project PROJECT_ID
gcloud services enable cloudasset.googleapis.com designcenter.googleapis.com \
  appoptimize.googleapis.com apphub.googleapis.com --project PROJECT_ID

Cautions

  • It can store data in any data center in the world: don't enable it in projects with data residency or customer-managed encryption key (CMEK) requirements.
  • If the project is inside a VPC Service Controls perimeter, set it up with gcloud, because the console needs the App Optimize API, which VPC Service Controls doesn't support.

What it can do

AreaExamples
Design and buildNatural language architecture design in Application Design Center; generate and refine gcloud commands, kubectl manifests, and Terraform; pick IAM roles and understand policies
Support and troubleshootingInvestigations that analyze logs, metrics, and configurations like a user-guided SRE; automatic investigations when an alert fires; performance issues in Cloud SQL, AlloyDB, BigQuery, and Spanner; handoff to support with context
ObservabilityExplore metrics, logs, alerts, and errors in natural language
OptimizeQuestions about spend (extends Cloud Hub Optimization and Cost Explorer), FinOps Hub, daily cost anomaly analysis, Storage Insights, Flow Analyzer
PlatformProactive agents that act with their own service account (Agent Identity) and are audit-logged; MCP to use it from Gemini CLI or other clients; custom instructions

Where you use it

Cloud Assist panel

Conversational help in the console and the Cloud mobile app.

Console quick prompts

Buttons and interactive elements throughout the console.

Cloud Hub

Cost and utilization optimization of resources and applications for DevOps teams.

Database Center

Centralized management of the database fleet.

Application Design Center

Design applications from technical and business requirements.

Investigations

Diagnosis from the console, the mobile app, the CLI, and IDEs.

Exam scenarios

SituationAnswerWhy
Find every resource with public access (allUsers) in the organizationgcloud asset search-all-iam-policies with memberTypesSearches allow policies across the hierarchy.
Analyze the organization's full inventory with SQLgcloud asset export to BigQueryExports a metadata snapshot.
Get notified every time someone changes a bucket's IAM policyCloud Asset Inventory feed to Pub/SubReal-time change notification.
Find out what a resource looked like 20 days agoCloud Asset Inventory historyKeeps 35 days of history.
Check in production whether a VM exists right nowCall the service APICloud Asset Inventory isn't for real-time queries.
Investigate an error with AI from logs and metricsGemini Cloud Assist investigationExplores hypotheses and traces the root cause.
Generate a gcloud command or Terraform code from natural languageCloud Assist panel chatGenerates and refines IaC.

Common exam traps

❓ How much history does Cloud Asset Inventory keep?

35 days of create, update, and delete history.

❓ Through which channel do feed notifications arrive?

A Pub/Sub topic.

❓ Which role lets you read the inventory?

Cloud Asset Viewer (roles/cloudasset.viewer).

❓ Can you append an export to a BigQuery table that already has data?

Only if it is partitioned. Otherwise the table must be empty or overwritten with --output-bigquery-force.

❓ Which roles does a user need to use Gemini Cloud Assist?

Gemini Cloud Assist User and Cloud Asset Viewer, plus roles for the products they ask about.

❓ Should you enable Gemini Cloud Assist in a project with data residency requirements?

No. It can store data in any Google Cloud data center in the world.

Did you get this topic?

Test what you just learned

The security team wants a function to run automatically every time someone changes the IAM policy of any project in a folder. What should they configure?

Ready to test "Cloud Asset Inventory and Gemini Cloud Assist"?

Original questions, each with a full explanation.

Start a mock exam