Cloud Asset Inventory 總覽

Cloud Asset Inventory 是一項全球中繼資料資產管理服務,可讓您查看、搜尋、匯出、監控及分析 Google Cloud 資產中繼資料,並提供最多 35 天的建立、更新和刪除記錄。如果素材資源在過去 35 天內沒有變更,系統會回報最新狀態。

資產中繼資料可能來自下列位置:

  • Google Cloud 資源,例如 Compute Engine VM 執行個體、Cloud Storage 值區和 App Engine 執行個體。

  • 在 Google Cloud 資源上設定的政策,例如 IAM 政策、組織政策和 Access Context Manager 政策。

  • 執行階段資訊 (來自 OS 庫存管理服務)。

以下說明如何使用素材資源:

素材資源類型、素材資源名稱和內容類型

Cloud Asset Inventory 提供多種與資產互動的方法。視您使用的方法和所需的回應詳細資料而定,您可能需要在要求中指定資產類型、資產名稱和內容類型。

資產類型

部分 Cloud Asset Inventory 方法會根據資產類型傳回結果。資產類型包括 Google Cloud 資源、政策、OS 庫存執行階段資訊和關係。如要瞭解可用的資產類型,以及支援這些類型的 Cloud Asset Inventory 方法,請參閱「資產類型」。

資產名稱

部分 Cloud Asset Inventory 方法會根據資產名稱傳回結果。指定資產名稱時,請務必使用完整資源名稱。如需完整的資源名稱清單,請參閱「資產名稱」。

內容類型

如要要求資源的額外中繼資料,請指定中繼資料內容類型。如果未指定內容類型,系統只會傳回基本回應,其中包含資產名稱、上次更新時間,以及所屬專案、資料夾和機構等資訊。

內容類型名稱會因您與 Cloud Asset Inventory 的互動方式而異。 RPC 和 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 執行階段 OS 庫存資訊。如要啟用 OS 庫存,請完成「設定 VM 管理員」中的相關步驟。
RELATIONSHIP relationship

需要存取 Security Command Center 進階或 Enterprise 方案,或 Gemini Cloud Assist

許多 Google Cloud 資產會透過關係相互連結。舉例來說,Compute 執行個體群組可以包含 Compute 執行個體,而 GKE 叢集可以包含 節點

關係資料自 2022 年 5 月 30 日起提供。關係可能有自己的更新時間戳記,因為關係的推斷時間可能與來源資產的更新時間不同。

如需支援的關係清單,請參閱「 關係類型」。

RESOURCE resource 資源的中繼資料。

不同內容類型對回覆的影響

下列範例顯示透過 Cloud Asset Inventory 列出專案中的 VM 執行個體時,不同內容類型會如何影響回應。

沒有內容類型

列出 VM 執行個體時,如果未指定任何內容類型,您只會收到執行個體名稱、上次更新時間,以及所屬專案、資料夾和機構。

展開可查看回覆範例

---
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 內容類型,系統也會提供 VM 的 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 內容類型,也會收到與 VM 相關聯的所有中繼資料。

展開可查看回覆範例

---
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[email protected]
      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 Premium 或 Enterprise 級別的存取權,或是 Gemini Cloud Assist

如果您指定 RELATIONSHIP 內容類型,也會收到與 VM 執行個體相關資產相關聯的中繼資料。

展開可查看回覆範例

---
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 可能會遺漏部分資料更新。

除非資源類型表格中另有註明,否則幾乎所有資產更新都會在幾分鐘內完成。

後續步驟