Security teams cannot protect Google Cloud resources and identities they cannot find, and in a large organisation those are spread across hundreds of projects and folders. Cloud Asset Inventory is the Google Cloud service that holds metadata for resources, IAM allow policies, organisation policies and access policies across an organisation, and lets you search, export and watch that metadata from one place. This guide shows how to use it for security work: the queries that find risky grants and service accounts, the permissions the caller needs at organisation scope, exports to BigQuery, Pub/Sub feeds for change detection and Policy Analyzer for effective access. It is written for Google Cloud security and platform engineers. For the wider platform baseline, see the Google Cloud Security Guide.
This is an independent guide from NHI Mgmt Group, based on Google Cloud's public documentation as of November 2026. It is not sponsored or reviewed by Google. Product features change, so confirm settings against Google Cloud's current documentation.
Key takeaways
- Search at organisation scope. Run searches with
--scope=organizations/ORGANIZATION_IDso one query covers every folder and project, rather than looping over projects. - Grant read access deliberately. Cloud Asset Viewer at organisation level lets a principal read IAM policies and resource metadata everywhere, so treat it as a sensitive role for people and automation alike.
- Search shows direct grants, Policy Analyzer shows effective access.
searchAllIamPoliciesreturns the bindings written on each resource; Policy Analyzer resolves inheritance, groups and roles into who can actually do what. - Feeds turn inventory into detection. A feed publishes every matching change to a Pub/Sub topic, with the prior state attached, so new owner grants, public bindings or service account keys can raise alerts within minutes.
- It is the best starting point for NHI discovery. Service accounts, service account keys, API keys and the bindings that grant them access are all searchable asset types.
What Cloud Asset Inventory is
Google describes Cloud Asset Inventory as a global metadata inventory service to view, search, export, monitor and analyse asset metadata. It keeps create, update and delete history for 35 days. It is not designed for real-time querying: for the live state of one resource, call that service's own API. Some changes take time to appear; the supported asset types page notes, for example, that disabling or enabling a service account can take up to 48 hours to be reflected.
What you get back depends on the content type you request. With no content type, responses carry only basic information: asset name, last update time and ancestors.
| Content type | What it returns | Security use |
|---|---|---|
RESOURCE | Full resource metadata (also used for organisation policy v2 as orgpolicy.googleapis.com/Policy) | Configuration review, public IPs, storage settings, constraint coverage |
IAM_POLICY | IAM allow policy bindings attached to each resource | Privilege review, external and public principals |
ORG_POLICY | Legacy organisation policy (v1) | Older constraint checks |
ACCESS_POLICY | Access Context Manager policies (exportable only at organisation level) | VPC Service Controls perimeter review |
OS_INVENTORY | Runtime OS inventory from VM Manager | Package and patch visibility on Compute Engine |
RELATIONSHIP | Links between assets, such as instance to instance group (Security Command Center Premium or Enterprise) | Blast radius and dependency mapping |
Permissions needed at organisation scope
Google's roles page lists two predefined roles, granted on an organisation, folder or project: Cloud Asset Viewer (roles/cloudasset.viewer) to read metadata, and Cloud Asset Owner (roles/cloudasset.owner) which adds feed management. Every call also needs serviceusage.services.use, for example through roles/serviceusage.serviceUsageConsumer, and the Cloud Asset Inventory API must be enabled in the project you call from. To search the whole organisation, grant the role on the organisation node.
| Task | Permission |
|---|---|
| Search resources | cloudasset.assets.searchAllResources |
| Search IAM allow policies | cloudasset.assets.searchAllIamPolicies |
| Export | One per content type, e.g. cloudasset.assets.exportResource, cloudasset.assets.exportIamPolicy |
| Create or update feeds | cloudasset.feeds.create or .update, plus the export permission for the content type |
| Policy Analyzer | cloudasset.assets.analyzeIamPolicy, searchAllIamPolicies and searchAllResources; iam.roles.get to expand custom roles |
Because an organisation-wide viewer can map every privileged binding in the estate, grant it to a named security group and to dedicated inventory service accounts, not to broad engineering groups. See the Google Cloud IAM and Service Accounts Guide.
Search resources and IAM policies
There are two search methods, both available through REST (POST https://cloudasset.googleapis.com/v1/SCOPE:searchAllResources and :searchAllIamPolicies) and gcloud. Scope can be projects/PROJECT_ID, folders/FOLDER_ID or organizations/ORGANIZATION_ID. Results page at up to 500 per request. Use --asset-types (RE2 regular expressions allowed) to narrow results, --read-mask to choose fields and --order-by to sort.
Example command shape:
gcloud asset search-all-iam-policies --scope=organizations/ORGANIZATION_ID --query='memberTypes:(allUsers OR allAuthenticatedUsers)'
Query examples for security reviews
| Question | Method | Query and options |
|---|---|---|
| Which resources are open to the public or to any Google account? | searchAllIamPolicies | memberTypes:(allUsers OR allAuthenticatedUsers) |
| Who holds Owner directly? | searchAllIamPolicies | roles:roles/owner |
| Who can change IAM policy at any level? | searchAllIamPolicies | policy.role.permissions:(resourcemanager.organizations.setIamPolicy OR resourcemanager.folders.setIamPolicy OR resourcemanager.projects.setIamPolicy) |
| Which bindings mention an external domain? | searchAllIamPolicies | policy:"domain:example.com" (repeat per partner domain) |
| Where is a given service account granted access? | searchAllIamPolicies | policy:"serviceAccount:NAME@PROJECT_ID.iam.gserviceaccount.com" |
| Which bindings grant roles to service accounts at all? | searchAllIamPolicies | memberTypes:serviceAccount |
| List every service account | searchAllResources | --asset-types=iam.googleapis.com/ServiceAccount |
| List user-managed service account keys | searchAllResources | --asset-types=iam.googleapis.com/ServiceAccountKey |
| List API keys | searchAllResources | --asset-types=apikeys.googleapis.com/Key |
| Which custom roles include a sensitive permission? | searchAllResources | --asset-types=iam.googleapis.com/Role with includedPermissions:iam.serviceAccountKeys.create |
| Find deny policies | searchAllResources | name:denypolicies with --asset-types=iam.googleapis.com/PolicyV2 |
| Find VMs with external IPs | searchAllResources | --asset-types=compute.googleapis.com/Instance and externalIPs:* |
| Find unlabelled or out-of-region resources | searchAllResources | NOT labels.env:*; NOT location:europe-* |
Query syntax points that catch people out: = is an exact match and : a partial match; the policy field accepts only :; and queries on roles and memberTypes return direct grants only, not access inherited from a folder or the organisation. Not every resource type is searchable, so check the supported asset types page before relying on a query for coverage. Search is synchronous and large inventories can consume quota quickly; Google recommends the asynchronous methods (export, long-running analysis) for those cases.
Export and feeds
Export to BigQuery for history and joins
Search answers a question now; export builds a dataset you can join and trend. gcloud asset export --organization=ORGANIZATION_ID --content-type=iam-policy --bigquery-table=projects/P/datasets/D/tables/T --output-bigquery-force writes a snapshot as a long-running operation (check it with gcloud asset operations describe). Useful options from the documentation:
- Snapshot time:
--snapshot-timemay be up to 35 days in the past, which lets you reconstruct what a policy looked like before an incident. - Per asset type:
--per-asset-typewrites one table per type, which keeps schemas typed and queries simpler. - Appending: appending needs a partitioned table; otherwise the destination must be empty or overwritten. Clustered tables are not supported, and a second export to the same destination within 15 minutes of a running one is rejected.
- Cloud Storage: export to a bucket instead when another tool ingests files.
A daily scheduled export of RESOURCE and IAM_POLICY into a dedicated, access-restricted dataset is the usual foundation for posture dashboards and access reviews. Protect that dataset: it is a map of every privileged identity in the organisation.
Feeds to Pub/Sub for change detection
A feed watches named assets or asset types and publishes each change to a Pub/Sub topic you have already created. The Cloud Asset Inventory service agent must be allowed to publish to that topic. Key facts from the documentation:
- Command:
gcloud asset feeds create FEED_ID --organization=ORGANIZATION_ID --pubsub-topic=projects/P/topics/T --asset-types=... --content-type=iam-policy, optionally with--condition-expression. - Message: each message is a
TemporalAssetwith the currentasset, thepriorAsset,priorAssetStateand a timewindow, so a consumer can diff old and new bindings. The first message on a new topic is a welcome string. - Conditions: written in CEL against
temporal_asset. For example, new assets only:temporal_asset.deleted == false && temporal_asset.prior_asset_state == google.cloud.asset.v1.TemporalAsset.PriorAssetState.DOES_NOT_EXIST. If a condition fails to evaluate, no notification is sent and the error is logged, so test conditions and watch those logs. - Limits: up to 200 feeds directly under one parent; creating or changing a feed can take up to 10 minutes to apply; a feed is deleted if its hosting project is permanently deleted, so host feeds in a long-lived security project.
Treat the topic and its subscription as security infrastructure. See the Google Cloud Pub/Sub Security guide for topic permissions and dead-letter handling.
Analysing access (Policy Analyzer)
Search tells you what is written in each policy. Policy Analyzer for allow policies answers the question security teams usually mean: who can actually reach a resource. It evaluates allow policies across a chosen organisation, folder or project and its descendants, and supports four query patterns: who can access a resource, which principals have given roles or permissions, what access a principal has on a resource, and which resources a principal can access.
- Expansion: groups expand to members (up to 1,000 per group, nested groups if you have the group permissions), roles expand to permissions, and resources expand to descendants.
- Scope limits: it does not evaluate deny policies, Principal Access Boundary policies, GKE RBAC or Cloud Storage ACLs, so a result is an upper bound on access from allow policies, not a final answer. Service account keys are not available in the analysis APIs.
- Quota: each organisation gets 20 analysis queries per day at no charge; more requires Security Command Center Premium or Enterprise activated at organisation level. Plan recurring analyses around that limit.
- Long-running export:
analyzeIamPolicyLongrunningwrites results to BigQuery or Cloud Storage, which suits quarterly access reviews.
| Need | Use | Why |
|---|---|---|
| Quick answer on direct grants | searchAllIamPolicies | Fast, no daily analysis quota |
| Effective access including inheritance and groups | Policy Analyzer | Resolves hierarchy, group membership and role contents |
| Trend over time, joins with HR or CMDB data | BigQuery export | Point-in-time snapshots and SQL |
| Alert on change | Feed to Pub/Sub | Event per change with prior state |
Security use cases
NHI and service account discovery
Machine identities usually outnumber people in a Google Cloud organisation, and many have no clear owner. A practical discovery run:
- List every
iam.googleapis.com/ServiceAccountat organisation scope, recording project, email and description. - List
iam.googleapis.com/ServiceAccountKeyassets to find user-managed keys, then compare with the key replacement plan in How to inventory Google Cloud service account keys and replace them with federation. - For each service account, search bindings with
policy:"serviceAccount:EMAIL"to see where it holds roles, including in other projects. - Flag service accounts holding basic roles (Owner, Editor) or
setIamPolicypermissions, and those grantedroles/iam.serviceAccountTokenCreatororroles/iam.serviceAccountUserto others, since those allow impersonation. - List
apikeys.googleapis.com/Keyassets and check each has API and application restrictions. - Join the results with usage data from the IAM recommender or audit logs to find accounts that hold roles but are not used.
See the Google Cloud Service Account Keys Security Guide for what to do with the keys you find.
Detections worth building on feeds
| Change | Feed scope | ATT&CK |
|---|---|---|
New binding to allUsers or allAuthenticatedUsers | IAM_POLICY, all types | T1530 Data from Cloud Storage |
New Owner or setIamPolicy grant at organisation or folder | IAM_POLICY on organisation and folders | T1098 Account Manipulation |
| New user-managed service account key | RESOURCE, iam.googleapis.com/ServiceAccountKey | T1098.001 Additional Cloud Credentials |
| New service account in a production project | RESOURCE, iam.googleapis.com/ServiceAccount | T1078.004 Cloud Accounts |
| Organisation policy constraint removed or changed | RESOURCE, orgpolicy.googleapis.com/Policy | Posture drift |
Pair feeds with Cloud Audit Logs, which say who made the change; the feed says what the resource now looks like. See the Google Cloud Audit Logs and Log Sinks Guide. Defenders should also remember that the same APIs help an intruder: organisation-wide asset search with a stolen viewer credential is a fast form of T1580 Cloud Infrastructure Discovery, so alert on unusual callers of SearchAllIamPolicies in Data Access logs where those are enabled.
Measurement
- Public bindings: count of resources with
allUsersorallAuthenticatedUsersbindings, target zero outside an approved list. - Direct Owner grants: number of principals with basic roles at project level and above, trending down.
- Key debt: user-managed service account keys, and their age distribution.
- Ownership: share of service accounts with a recorded owner label or description.
- Detection latency: time from a risky change to an alert from the feed pipeline, tested monthly with a planted change.
Framework mapping
| Framework | Reference | How Cloud Asset Inventory supports it |
|---|---|---|
| NIST CSF 2.0 | ID.AM-02, PR.AA-05, DE.CM-09 | Inventory of services, access review, monitoring of changes |
| NIST SP 800-53 Rev. 5 | CM-8, AC-2, AC-6, AU-6 | Component inventory, account management, least privilege evidence, review of records |
| CIS Controls v8.1 | Control 1, Control 5 (5.1) | Enterprise asset inventory; inventory of accounts including service accounts |
| ISO/IEC 27001:2022 | Annex A 5.9, 5.18 | Inventory of information and other associated assets; access rights |
Common failure patterns
- Project-by-project scripts: loops over the projects a user happens to see miss projects outside that view. Search and export at organisation scope instead.
- Reading direct grants as the whole truth: a
roles:roles/ownersearch misses Owner inherited from a folder or held through a group. Use Policy Analyzer for effective access before declaring a principal clean. - Over-broad viewer grants: giving Cloud Asset Viewer at organisation level to large groups or to CI service accounts hands an intruder a full privilege map.
- Feeds in short-lived projects: a feed disappears with its project, and a failed condition silently sends nothing. Host feeds centrally and alert when expected messages stop.
- Treating it as real-time: metadata can lag (up to 48 hours for service account enable or disable), so confirm with the service API before acting on a single result during an incident.
- Unprotected export datasets: a BigQuery dataset of every IAM policy readable by analysts and dashboards widens exposure. Restrict it like the policies themselves.
Practitioner checklist
- Enable the Cloud Asset Inventory API in a dedicated security project and grant Cloud Asset Viewer at organisation level only to a named security group and inventory service accounts.
- Run the public-binding, Owner and
setIamPolicysearches at organisation scope and record a baseline. - Build a full inventory of service accounts, user-managed keys and API keys, and assign an owner to each.
- Schedule a daily export of RESOURCE and IAM_POLICY to a restricted BigQuery dataset.
- Create organisation-level feeds for public bindings, privileged grants, new service account keys and organisation policy changes, and route them to the SOC.
- Test each feed condition with a planted change and alert when a feed goes quiet.
- Use Policy Analyzer, within its daily quota, for effective-access questions on crown-jewel resources.
- Track the five metrics above monthly and report the trend.
Standards and references
- Google Cloud: Cloud Asset Inventory overview
- Google Cloud: Search IAM allow policies
- Google Cloud: Search resources
- Google Cloud: Monitor asset changes
- Google Cloud: Export asset metadata to BigQuery
- Google Cloud: Cloud Asset Inventory roles and permissions
- Google Cloud: Policy Analyzer for allow policies
- Google Cloud: Supported asset types
Related NHI Mgmt Group resources: Google Cloud Security Guide · Google Cloud IAM and Service Accounts Guide · Google Cloud Organization Policy Guide · Security Command Center Guide