Cloud Asset Inventory 是一项全球元数据清点服务,可让您查看、搜索、导出、监控和分析 Google Cloud 资产元数据,最多可保留 35 天的创建、更新和删除历史记录。过去 35 天内未发生更改的素材资源会报告其最新状态。
资产元数据可以来自以下位置:
Google Cloud 资源,例如 Compute Engine 虚拟机实例、Cloud Storage 存储分区和 App Engine 实例。
对资源设置的政策,例如 IAM 政策、组织政策和 Access Context Manager 政策。 Google Cloud
OS Inventory Management 中的运行时信息。
您可以通过以下方式处理素材资源:
使用自定义查询语言搜索您的资源及其IAM 许可政策,或使用 BigQuery SQL 查询您的资源。
将资产元数据导出到 BigQuery 或 Cloud Storage。
分析资源的 IAM 和组织政策,以及查看资源的有效 IAM 政策,以了解谁有权访问哪些资源。
通过设置和订阅 Feed,监控资产是否发生了变化。
根据资产生成数据分析,以帮助您改善安全状况。
资产类型、资产名称和内容类型
Cloud Asset Inventory 提供了多种与资产互动的方法。根据您使用的方法和所需的响应详情,您可能需要在请求中指定资产类型、资产名称和内容类型。
资产类型
某些 Cloud Asset Inventory 方法会根据资产类型返回结果。资产类型包括 Google Cloud 资源、政策、操作系统目录运行时信息和关系。如需详细了解可用的资产类型以及支持这些类型的 Cloud Asset Inventory 方法,请参阅资产类型。
素材资源名称
某些 Cloud Asset Inventory 方法会根据资产名称返回结果。指定资产名称时,您必须使用其完整资源名称。如需查看完整资源名称的列表,请参阅资源名称。
内容类型
您可以通过指定元数据内容类型来请求资源的其他元数据。如果您未指定内容类型,则系统只会返回基本响应,其中包含资源名称、上次更新时间以及资源所属的项目、文件夹和组织等信息。
内容类型名称因您与 Cloud Asset Inventory 的交互方式而异。RPC API 和 REST API 的名称相同。不过,gcloud CLI 内容类型名称遵循不同的模式。为保持一致性并方便说明,本文档的其余部分将按 RPC 和 REST 名称引用内容类型。
下表详细介绍了内容类型及其说明:
| 内容类型 | 说明 | |
|---|---|---|
| RPC 和 REST 名称 | gcloud CLI 名称 | |
ACCESS_POLICY |
access-policy |
在资源上设置的 Access Context Manager 政策。 |
IAM_POLICY |
iam-policy |
与资源绑定的 IAM 政策元数据。 |
ORG_POLICY |
org-policy |
在资产上设置的组织政策元数据。此内容类型会输出旧版组织政策 v1。对于组织政策 v2,请尝试使用 resource 内容类型和 orgpolicy.googleapis.com/Policy 资源类型。
|
OS_INVENTORY |
os-inventory |
运行时操作系统清单信息。如需启用操作系统清点,请完成设置虚拟机管理器中的相关步骤。 |
RELATIONSHIP |
relationship |
需要有权访问 Security Command Center 高级或企业版层级,或 Gemini Cloud Assist。 许多 Google Cloud 素材资源之间通过关系相互关联。例如,Compute Engine 实例组可以包含 Compute Engine 实例,或者 GKE 集群可以包含 节点。 关系数据从 2022 年 5 月 30 日开始提供。关系可能具有自己的更新时间戳,因为它可能在与来源资产更新时间不同的时间推断出来。 如需查看支持的关系类型的列表,请参阅 关系类型。 |
RESOURCE |
resource |
资源的元数据。 |
回答会随内容类型而变化
以下示例展示了通过 Cloud Asset Inventory 以不同内容类型列出项目中的虚拟机实例时,响应会发生怎样的变化。
无内容类型
如果您在列出虚拟机实例时未指定内容类型,则只会收到实例名称、上次更新时间,以及它们所属的项目、文件夹和组织。
展开即可查看响应示例
--- ancestors: - projects/PROJECT_NUMBER - folders/FOLDER_NUMBER - organizations/ORGANIZATION_ID assetType: compute.googleapis.com/Instance name: //compute.googleapis.com/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME updateTime: '2023-11-15T12:28:30.087825Z'
IAM_POLICY 内容类型
如果您指定了 IAM_POLICY 内容类型,则还会收到虚拟机上的 IAM 绑定(如果有)。
展开即可查看响应示例
---
ancestors:
- projects/PROJECT_NUMBER
- folders/FOLDER_NUMBER
- organizations/ORGANIZATION_ID
assetType: compute.googleapis.com/Instance
iamPolicy:
bindings:
- members:
- user:USER_EMAIL_ADDRESS
role: roles/compute.securityAdmin
etag: ETAG
name: //compute.googleapis.com/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME
updateTime: '2023-12-19T23:35:42.673842Z'RESOURCE 内容类型
如果您指定了 RESOURCE 内容类型,则还会收到与该虚拟机关联的所有元数据。
展开即可查看响应示例
---
ancestors:
- projects/PROJECT_NUMBER
- folders/FOLDER_NUMBER
- organizations/ORGANIZATION_ID
assetType: compute.googleapis.com/Instance
name: //compute.googleapis.com/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME
resource:
data:
allocationAffinity:
consumeAllocationType: ANY_ALLOCATION
canIpForward: false
confidentialInstanceConfig:
enableConfidentialCompute: true
cpuPlatform: AMD Rome
creationTimestamp: '2023-11-14T14:35:37.059-08:00'
deletionProtection: false
description: ''
disks:
- architecture: X86_64
autoDelete: true
boot: true
deviceName: INSTANCE_NAME
diskSizeGb: '10'
guestOsFeatures:
- type: VIRTIO_SCSI_MULTIQUEUE
- type: SEV_CAPABLE
- type: SEV_SNP_CAPABLE
- type: SEV_LIVE_MIGRATABLE
- type: UEFI_COMPATIBLE
- type: GVNIC
index: 0
interface: NVME
licenses:
- https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-2004-lts
mode: READ_WRITE
shieldedInstanceInitialState:
dbx:
- content: DATA
fileType: BIN
dbxs:
- content: DATA
fileType: BIN
source: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/disks/INSTANCE_NAME
type: PERSISTENT
displayDevice:
enableDisplay: false
fingerprint: FINGERPRINT
id: 'ID'
keyRevocationActionType: NONE_ON_KEY_REVOCATION
labelFingerprint: LABEL_FINGERPRINT
lastStartTimestamp: '2023-11-15T04:28:30.005-08:00'
machineType: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/machineTypes/n2d-standard-2
name: INSTANCE_NAME
networkInterfaces:
- accessConfigs:
- name: External NAT
natIP: 34.27.105.222
networkTier: PREMIUM
type: ONE_TO_ONE_NAT
fingerprint: jKU51FdTluk=
name: nic0
network: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/default
networkIP: 10.128.15.212
nicType: GVNIC
stackType: IPV4_ONLY
subnetwork: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/subnetworks/default
reservationAffinity:
consumeReservationType: ANY_ALLOCATION
resourceStatus: {}
scheduling:
automaticRestart: true
onHostMaintenance: TERMINATE
preemptible: false
provisioningModel: STANDARD
selfLink: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME
serviceAccounts:
- email: PROJECT_NUMBER-compute@developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring.write
- https://www.googleapis.com/auth/servicecontrol
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/trace.append
shieldedInstanceConfig:
enableIntegrityMonitoring: true
enableSecureBoot: false
enableVtpm: true
shieldedInstanceIntegrityPolicy:
updateAutoLearnPolicy: true
startRestricted: false
status: RUNNING
tags:
fingerprint: FINGERPRINT
zone: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE
discoveryDocumentUri: https://www.googleapis.com/discovery/v1/apis/compute/v1/rest
discoveryName: Instance
location: ZONE
parent: //cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER
version: v1
updateTime: '2023-11-15T12:28:30.087825Z'RELATIONSHIP 内容类型
关联关系需要有权访问 Security Command Center 高级或企业版或 Gemini Cloud Assist。
如果您指定了 RELATIONSHIP 内容类型,则还会收到与虚拟机实例的相关资产关联的元数据。
展开即可查看响应示例
--- ancestors: - projects/PROJECT_NUMBER - folders/FOLDER_NUMBER - organizations/ORGANIZATION_ID assetType: compute.googleapis.com/Instance name: //compute.googleapis.com/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME relatedAsset: ancestors: - projects/PROJECT_NUMBER - folders/FOLDER_NUMBER - organizations/ORGANIZATION_ID asset: //compute.googleapis.com/projects/PROJECT_ID/zones/ZONE/disks/INSTANCE_NAME assetType: compute.googleapis.com/Disk relationshipType: COMPUTE_INSTANCE_USE_DISK updateTime: '2023-12-19T23:35:42.673842Z'
使用 RELATIONSHIP 内容类型时,您可以请求特定的关系类型,而不是请求所有关系。
数据新鲜度
Cloud Asset Inventory 可确保当前数据最终一致,并尽力确保历史数据一致。虽然很少见,但 Cloud Asset Inventory 可能会错过一些数据更新。
除非资源类型表格中另有说明,否则几乎所有资产更新都只需几分钟即可生效。