查看金鑰使用情形

本頁面說明如何查看貴機構中受 Cloud KMS 金鑰保護的 Google Cloud 資源。金鑰使用情況追蹤功能僅適用於機構資源。

您可以查看金鑰保護的資源資訊,分為兩個層級:

  • 每個金鑰的金鑰用量摘要資訊包括受保護資源、專案和使用金鑰的專屬 Google Cloud 產品數量。只要使用者具備金鑰的 Cloud KMS 檢視者角色,就能查看這類詳細資料。
  • 金鑰使用詳細資料資訊會指出哪些資源受到這個金鑰保護,並依賴這個金鑰。這類詳細資料屬於機密資訊,只有在機構中具備 Cloud KMS 受保護的資源檢視者角色的帳戶才能存取。

事前準備

本頁面假設您是在Google Cloud 機構資源中使用 Cloud KMS。

  1. 啟用 Cloud KMS Inventory API。

    啟用 API

必要的角色

為確保 Cloud KMS 服務帳戶具備啟用金鑰使用情形追蹤功能所需的權限,請管理員授予 Cloud KMS 服務帳戶貴機構的 Cloud KMS 組織服務代理 (roles/cloudkms.orgServiceAgent) IAM 角色。

<

如要取得查看金鑰使用資訊所需的權限,請要求管理員在金鑰中授予您下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

查看金鑰使用情形資訊

控制台

  1. 前往 Google Cloud 控制台的「Key Inventory」頁面。

    前往「重要廣告空間」

  2. 選用:如要篩選金鑰清單,請在「filter_list」filter_list「Filter」方塊中輸入搜尋字詞,然後按下 Enter 鍵。舉例來說,您可以依金鑰的位置、金鑰環、狀態或其他屬性篩選。

  3. 按一下要查看使用資訊的金鑰名稱。

  4. 按一下「用量追蹤」分頁標籤。

  5. 選用:如要篩選受保護資源清單,請在「filter_list」(篩選器)filter_list 篩選器方塊中輸入搜尋字詞,然後按下 Enter 鍵。

系統會顯示所選金鑰的使用摘要和詳細資料。

gcloud CLI

如要在指令列上使用 Cloud KMS,請先安裝或升級至最新版本的 Google Cloud CLI

如要查看金鑰使用情況摘要,請使用 get-protected-resources-summary 方法:

gcloud kms inventory get-protected-resources-summary \
    --keyname  projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME \

更改下列內容:

  • PROJECT_ID:包含金鑰環的專案 ID。
  • LOCATION:金鑰環的 Cloud KMS 位置。
  • KEY_RING:金鑰所屬金鑰環的名稱。
  • KEY_NAME:要查看使用量摘要的金鑰名稱。

如要查看金鑰使用情形詳細資料,請使用 search-protected-resources 方法:

gcloud kms inventory search-protected-resources \
    --keyname  projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME \
    --scope=organizations/ORGANIZATION_ID

更改下列內容:

  • PROJECT_ID:包含金鑰環的專案 ID。
  • LOCATION:金鑰環的 Cloud KMS 位置。
  • KEY_RING:金鑰所屬金鑰環的名稱。
  • KEY_NAME:要查看使用詳細資料的金鑰名稱。
  • ORGANIZATION_ID:貴機構的數字 ID。

API

這些範例使用 curl 做為 HTTP 用戶端,示範如何使用 API。如要進一步瞭解存取權控管,請參閱「存取 Cloud KMS API」一文。

如要查看金鑰使用情況摘要,請使用 cryptoKeys.getProtectedResourcesSummary 方法:

curl  "https://kmsinventory.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME/protectedResourcesSummary"
    --request "GET" \
    --header "x-goog-user-project: CALLING_PROJECT_ID"
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer TOKEN"

更改下列內容:

  • PROJECT_ID:包含金鑰環的專案 ID。
  • LOCATION:金鑰環的 Cloud KMS 位置。
  • KEY_RING:金鑰所屬金鑰環的名稱。
  • KEY_NAME:您要查看使用量摘要的金鑰名稱。
  • CALLING_PROJECT_ID:您要從中呼叫 KMS Inventory API 的專案 ID。

如要查看金鑰使用情形詳細資料,請使用 protectedResources.search 方法:

curl "https://kmsinventory.googleapis.com/v1/organizations/ORGANIZATION_ID/protectedResources:search?crypto_key=projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME"
    --request "GET" \
    --header "x-goog-user-project: CALLING_PROJECT_ID"
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer TOKEN"

更改下列內容:

  • ORGANIZATION_ID:貴機構的數字 ID。
  • PROJECT_ID:包含金鑰環的專案 ID。
  • LOCATION:金鑰環的 Cloud KMS 位置。
  • KEY_RING:金鑰所屬金鑰環的名稱。
  • KEY_NAME:要查看使用詳細資料的金鑰名稱。
  • CALLING_PROJECT_ID:您要從中呼叫 KMS Inventory API 的專案 ID。

金鑰使用詳細資料

使用所選金鑰加密的受保護資源使用情況詳細資料包括:

  • 名稱:受所選金鑰保護的 Google Cloud 資源名稱。
  • 專案:含有受保護資源的專案名稱。
  • 加密編譯金鑰版本:用來加密這項資源的金鑰版本。 部分受保護的資源不會回報加密編譯金鑰版本。
  • Cloud 產品:與這個資源相關聯的 Google Cloud 產品。
  • 資源類型:受保護的資源類型,例如 Bucket (Cloud Storage) 或 Disk (Compute Engine)。
  • 位置:與資源相關聯的 Google Cloud 區域。
  • 建立日期:資源的建立時間。
  • 標籤:與資源相關聯的鍵/值組合。

列出保護資源的金鑰版本

如果資源受到多個金鑰版本保護,您可能無法在「使用情況追蹤」分頁中看到完整的金鑰版本清單。

如要列出保護資源的金鑰版本,請使用 gcloud CLI 執行下列指令:

gcloud beta kms inventory search-protected-resources \
  --keyname=KEY_NAME \
  --scope=organizations/ORGANIZATION_ID \
  --filter="name:RESOURCE_NAME" \
  --flatten="cryptoKeyVersions" \
  --format="value(cryptoKeyVersions)"

更改下列內容:

  • KEY_NAME:要列出金鑰版本的金鑰名稱。
  • ORGANIZATION_ID:貴機構的數字 ID。
  • RESOURCE_NAME:要列出金鑰版本的資源名稱。

限制

使用金鑰用量追蹤功能時,請注意下列事項:

  • 金鑰使用情形追蹤功能僅適用於 CMEK 金鑰使用情形。如果您在應用程式內或外部使用金鑰版本, Google Cloud 「使用量追蹤」分頁不會顯示這類使用量。
  • 系統不會追蹤部分 CMEK 資源。如果資源類型未列於「追蹤的資源類型」中,金鑰使用情形詳細資料可能不會包含金鑰使用情形資訊。舉例來說,Datastream 用於加密 ConnectionProfile (datastream.googleapis.com/ConnectionProfile) 資源的金鑰用量不會顯示在「用量追蹤」分頁中。
  • 資料可能會延遲顯示。舉例來說,如果您建立新的受保護資源,受保護資源和相關聯的金鑰版本不會立即新增至「用量追蹤」分頁。
  • Cloud Storage 金鑰使用資料須遵守下列額外限制:
    • 系統會將物件的主要用量資料匯總至值區。不會顯示物件名稱。如果值區至少有一個物件使用某個金鑰,該值區就會顯示為使用該金鑰。
    • 如果 bucket 包含以超過 4000 個不重複金鑰版本保護的物件,金鑰使用情況追蹤可能不完整。
  • 金鑰使用情形追蹤詳細資料僅供參考,請先使用其他來源進行盡職調查,再進行可能導致服務中斷或資料遺失的變更。請勿僅根據金鑰使用情形追蹤資訊停用或刪除金鑰版本。

追蹤的資源類型

支援的資源類型如下:

    服務 資源
    AlloyDB for PostgreSQL alloydb.googleapis.com/Backup
    AlloyDB for PostgreSQL alloydb.googleapis.com/Cluster
    Apigee apigee.googleapis.com/Organization
    Apigee apigee.googleapis.com/Instance
    Apigee API 中心 apihub.googleapis.com/ApiHubInstance
    Artifact Registry artifactregistry.googleapis.com/Repository
    BigQuery bigquery.googleapis.com/Dataset
    BigQuery bigquery.googleapis.com/Model
    BigQuery bigquery.googleapis.com/Table
    BigQuery bigquerydatatransfer.googleapis.com/TransferConfig
    Bigtable bigtableadmin.googleapis.com/Backup
    Bigtable bigtableadmin.googleapis.com/Cluster
    Bigtable bigtableadmin.googleapis.com/Table
    Cloud Composer composer.googleapis.com/Environment
    Cloud Data Fusion datafusion.googleapis.com/Instance
    Cloud Healthcare API healthcare.googleapis.com/Dataset
    Cloud Logging logging.googleapis.com/LogBucket
    Cloud Run run.googleapis.com/Revision
    Cloud Run 函式 cloudfunctions.googleapis.com/CloudFunction
    Cloud Run 函式 cloudfunctions.googleapis.com/Function
    Cloud SQL sqladmin.googleapis.com/BackupRun
    Cloud SQL sqladmin.googleapis.com/Instance
    Cloud Storage storage.googleapis.com/Bucket
    Cloud Workstations workstations.googleapis.com/Workstation
    Cloud Workstations workstations.googleapis.com/WorkstationConfig
    Compute Engine compute.googleapis.com/Disk
    Compute Engine compute.googleapis.com/Image
    Compute Engine compute.googleapis.com/MachineImage
    Compute Engine compute.googleapis.com/Snapshot
    資料庫移轉服務 datamigration.googleapis.com/MigrationJob
    資料庫移轉服務 datamigration.googleapis.com/ConnectionProfile
    Dataflow dataflow.googleapis.com/Job
    Dataproc dataproc.googleapis.com/Cluster
    Dataproc dataproc.googleapis.com/Batch
    Dataproc Metastore metastore.googleapis.com/Service
    Datastream datastream.googleapis.com/Stream
    Document AI documentai.googleapis.com/HumanReviewConfig
    Document AI documentai.googleapis.com/Processor
    Document AI documentai.googleapis.com/ProcessorVersion
    Filestore file.googleapis.com/Instance
    Filestore file.googleapis.com/Backup
    Firestore firestore.googleapis.com/Database
    Firestore datastore.googleapis.com/Database
    Gemini Enterprise Enterprise discoveryengine.googleapis.com/DataStore
    Google Kubernetes Engine container.googleapis.com/Cluster
    Looker (Google Cloud Core) looker.googleapis.com/Instance
    Memorystore for Redis redis.googleapis.com/Instance
    Migrate to Virtual Machines vmmigration.googleapis.com/Source
    Pub/Sub pubsub.googleapis.com/Topic
    Secret Manager secretmanager.googleapis.com/Secret
    Secret Manager secretmanager.googleapis.com/SecretVersion
    Secure Source Manager securesourcemanager.googleapis.com/Instance
    Spanner spanner.googleapis.com/Database
    Vertex AI aiplatform.googleapis.com/Dataset
    Vertex AI aiplatform.googleapis.com/Featurestore
    Vertex AI aiplatform.googleapis.com/Tensorboard
    Vertex AI aiplatform.googleapis.com/BatchPredictionJob
    Vertex AI aiplatform.googleapis.com/CustomJob
    Vertex AI aiplatform.googleapis.com/Endpoint
    Vertex AI aiplatform.googleapis.com/Model
    Vertex AI aiplatform.googleapis.com/TrainingPipeline
    Vertex AI aiplatform.googleapis.com/PipelineJob
    Vertex AI aiplatform.googleapis.com/MetadataStore
    Vertex AI Search discoveryengine.googleapis.com/DataStore
    Vertex AI Workbench 執行個體 notebooks.googleapis.com/Instance
    工作流程 workflows.googleapis.com/Workflow