本頁面說明如何查看貴機構中受 Cloud KMS 金鑰保護的 Google Cloud 資源。金鑰使用情況追蹤功能僅適用於機構資源。
您可以查看金鑰保護的資源資訊,分為兩個層級:
- 每個金鑰的金鑰用量摘要資訊包括使用該金鑰的受保護資源、專案和不重複 Google Cloud 產品數量。只要使用者具備金鑰的 Cloud KMS 檢視者角色,就能查看這類詳細資料。
- 金鑰使用詳細資料資訊會指出哪些資源受到這個金鑰保護,並依賴這個金鑰。這類詳細資料屬於機密資訊,只有在機構中擁有 Cloud KMS 受保護的資源檢視者角色的帳戶才能存取。
事前準備
本頁面假設您在Google Cloud 機構資源中使用 Cloud KMS。
請貴機構管理員在機構資源上,將 Cloud KMS 機構服務代理人 (
cloudkms.orgServiceAgent
) 角色授予 Cloud KMS 服務帳戶。這個角色不適用於 Google Cloud 控制台,因此您必須使用 gcloud CLI 授予角色:gcloud CLI
gcloud organizations add-iam-policy-binding ORGANIZATION_ID \ --member=serviceAccount:service-org-ORGANIZATION_ID@gcp-sa-cloudkms.iam.gserviceaccount.com \ --role=roles/cloudkms.orgServiceAgent
將
ORGANIZATION_ID
替換為機構的數字 ID。將 Cloud KMS 檢視者 (
roles/cloudkms.viewer
) 角色授予需要查看金鑰用量摘要的使用者。如要瞭解如何授予角色,請參閱「管理存取權」。將機構資源的 Cloud KMS 受保護的資源檢視者 (
roles/cloudkms.protectedResourcesViewer
) 角色授予需要查看金鑰使用詳細資料的使用者。這個角色無法在 Google Cloud 控制台中使用,因此您必須使用 gcloud CLI 授予角色:gcloud CLI
gcloud organizations add-iam-policy-binding ORGANIZATION_ID \ --member=user:USER_EMAIL \ --role=roles/cloudkms.protectedResourcesViewer
更改下列內容:
ORGANIZATION_ID
:機構的數值 ID。USER_EMAIL
:使用者的電子郵件地址。
啟用 Cloud KMS Inventory API。
查看金鑰使用情形資訊
控制台
前往 Google Cloud 控制台的「Key Inventory」頁面。
選用:如要篩選金鑰清單,請在「filter_list」filter_list「Filter」(篩選器) 方塊中輸入搜尋字詞,然後按下 Enter 鍵。舉例來說,您可以依金鑰的位置、金鑰環、狀態或其他屬性篩選。
按一下要查看使用資訊的金鑰名稱。
按一下「用量追蹤」分頁標籤。
選用:如要篩選受保護資源清單,請在「filter_list」(篩選器) filter_list「Filter」(篩選器) 方塊中輸入搜尋字詞,然後按下 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 個不重複金鑰版本保護的物件,金鑰使用情況追蹤可能不完整。
- 金鑰使用情形追蹤詳細資料僅供參考,請先透過其他來源進行盡職調查,再進行可能導致服務中斷或資料遺失的變更。請勿僅根據金鑰使用情形追蹤資訊停用或刪除金鑰版本。
追蹤的資源類型
支援的資源類型如下:
服務 | 資源 |
---|---|
AI Applications | discoveryengine.googleapis.com/DataStore |
AlloyDB for PostgreSQL | alloydb.googleapis.com/Backup |
AlloyDB for PostgreSQL | alloydb.googleapis.com/Cluster |
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 |
Google Agentspace 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 Workbench 執行個體 | notebooks.googleapis.com/Instance |
工作流程 | workflows.googleapis.com/Workflow |