本頁面說明 Security Command Center API 第 1 版 (v1) 和第 2 版 (v2) 的差異。本文也說明如何搭配 v1 Security Command Center Management API,遷移至 v2 Security Command Center API。
自 2024 年 12 月 9 日起,如果您在機構中首次啟用 Security Command Center,則只能在該機構中使用 Security Command Center API 第 2 版。而不支援先前的版本。
如果您在 2024 年 12 月 9 日前啟用專案層級的 Security Command Center,則在相同機構中啟用的任何專案,都會支援所有可用的 Security Command Center API 版本。
對於所有與 Security Command Center 的整合,我們建議您採用 v2 Security Command Center API 和 v1 Security Command Center Management API。建議您使用 Cloud 用戶端程式庫或 Google Cloud Terraform 供應商呼叫這些 API。如要瞭解詳情,請參考下列資源:
Terraform
用戶端程式庫
v1 與 v2 API 的差異
遷移至 v2 Security Command Center API 時,請注意與 v1 API 的下列差異。
資料落地
第 2 版 Security Command Center API 支援資料落地,可讓您進一步控管 Security Command Center 資料的儲存位置。
如果貴機構已啟用資料落地功能,您必須執行下列操作,才能存取受資料落地控制項限制的資源:
- 使用區域服務端點存取資源。
- 呼叫資源的方法時,請指定位置。
如果貴機構未啟用資料落地功能,建議您呼叫每個方法的「位置資訊感知」版本,並指定 global
位置。這樣做可讓您日後更輕鬆地採用資料落地功能。
如要使用各個方法的感應位置版本,請按照下列步驟操作:
控制台
Google Cloud 主控台會在必要時使用各方法的感知位置版本。
gcloud
執行可指定位置的 gcloud CLI 指令 (例如 gcloud scc findings list
) 時,請務必提供位置。做法如下:
- 使用
--location
標記。 - 如果提供資源名稱的完整路徑,請使用指定位置的格式,例如
projects/123/sources/456/locations/global/findings/a1b2c3
。
Terraform
請一律為支援的資源提供 location
引數,例如 google_scc_v2_organization_mute_config
。
REST
呼叫名稱包含 locations
的方法版本。舉例來說,請呼叫 organizations.locations.findings.bulkMute
,而不是 organizations.findings.bulkMute
。
用戶端程式庫
如要瞭解啟用資料落地設定後如何使用區域端點,請參閱「Security Command Center 區域端點」。
通知設定和 BigQuery 匯出設定
您可以使用 v1 Security Command Center API 建立及管理下列類型的匯出設定:
- 通知設定,可將發現項目傳送至 Pub/Sub
- BigQuery 匯出設定,可將發現項目串流至 BigQuery
您也可以使用 v2 Security Command Center API 建立及管理這些匯出設定。不過,如果您使用 v1 Security Command Center API 建立匯出設定,則該設定不會顯示在 v2 Security Command Center API 中。同樣地,如果您使用 v2 Security Command Center API 建立匯出設定,則該設定不會顯示在 v1 Security Command Center API 中。
此外,使用 v2 Security Command Center API 建立的匯出設定無法使用 source_properties
欄位篩選發現項目。請改用其他欄位。
控制台
在 Google Cloud 控制台中,如果匯出設定是使用 v1 Security Command Center API 建立,則會顯示「舊版」標籤。您可以使用Google Cloud 控制台管理這些資源。
如果您在 Google Cloud 控制台中建立新的匯出設定,系統一律會使用 v2 Security Command Center API 建立設定。
gcloud
如要管理使用 v1 Security Command Center API 建立的匯出設定,請執行 gcloud CLI 指令 (例如 gcloud scc notifications describe
) 時,不要指定位置:
- 請勿使用
--location
旗標。 - 如果您提供設定 ID 的完整路徑,請使用未指定位置的格式,例如
organizations/123/notificationConfigs/456
。請勿使用organizations/123/locations/global/notificationConfigs/456
等格式。
同樣地,如要使用 v2 Security Command Center API 建立或管理匯出設定,請在執行 gcloud CLI 指令時指定位置。建立新設定時,建議使用 v2 Security Command Center API。
Terraform
Terraform 設定檔會將匯出設定定義為 v1 或 v2 資源。舉例來說,請參閱下列通知設定資源:
- v1
- v2
建立新設定時,建議您建立 v2 資源。
REST
如要管理使用 v1 Security Command Center API 建立的匯出設定,必須使用 v1 Security Command Center API。
建立新設定時,建議使用 v2 Security Command Center API。
用戶端程式庫
如要管理使用 v1 Security Command Center API 建立的匯出設定,您必須使用 v1 Security Command Center API 的 Cloud Client Libraries。
建立新設定時,建議使用 v2 Security Command Center API。
內建服務和自訂模組
您可以使用 v1 Security Command Center API 查看及更新下列資源類型:
- Security Command Center 內建服務 及其啟用狀態
- 下列內建服務的自訂模組:
如要管理這些資源類型,請使用 Security Command Center Management API 和其用戶端程式庫。v2 Security Command Center API 無法管理這些資源類型。
資產管理
如果貴機構在 2023 年 6 月 20 日前啟用 Security Command Center,您可能會使用 v1 Security Command Center API,在機構、資料夾或專案中查看資產。這些 Security Command Center 資產管理功能已淘汰,不適用於 v2 版 Security Command Center API。這些功能將於 2024 年 6 月 20 日當天或之後,從 v1 Security Command Center API 中移除。
您可以改用 Cloud Asset Inventory 查看資產,包括安全標記。詳情請參閱「列出資產」。
您也可以使用 v2 Security Command Center API 更新資產的安全標記。更新安全標記的 Security Command Center API 方法並未淘汰。
更新用戶端程式庫和 Terraform 供應商
如要更新程式碼以使用 v2 Security Command Center API,請按照下列步驟操作:
Terraform
安裝最新版本的 Terraform 供應商,適用於 Google Cloud。詳情請參閱供應商說明文件。
此外,請更新 Terraform 設定檔,建立以 google_scc_v2_
或 google_scc_management_
前置字元開頭的資源。請注意,下列資源不會在 v1 和 v2 API 之間共用:
google_scc_folder_notification_config
google_scc_folder_scc_big_query_export
google_scc_notification_config
google_scc_organization_scc_big_query_export
google_scc_project_notification_config
google_scc_project_scc_big_query_export
如果您套用 Terraform 執行計畫,將這些資源替換為對應的 v2 版本,Terraform 就會刪除 v1 設定,並建立新的 v2 設定。
C++
更新應用程式,加入用戶端程式庫的 v2 標頭檔案:
#include "google/cloud/securitycenter/v2/security_center_client.h"
此外,請更新應用程式,使用 v2 命名空間中的類別:
namespace securitycenter = ::google::cloud::securitycenter_v2;
C#
安裝 v2 版用戶端程式庫,然後更新應用程式以使用該程式庫:
Install-Package Google.Cloud.SecurityCenter.V2
Go
安裝 v2 版用戶端程式庫,然後更新應用程式以使用該程式庫:
go get cloud.google.com/go/securitycenter/apiv2
Java
安裝最新版本的用戶端程式庫。詳情請參閱「安裝用戶端程式庫」。
此外,請更新應用程式,使用 com.google.cloud.securitycenter.v2
套件中的類別、介面和列舉。
Node.js
安裝最新版本的用戶端程式庫。詳情請參閱「安裝用戶端程式庫」。
此外,請更新應用程式,使用 v2.SecurityCenterClient
和 protos.google.cloud.securitycenter.v2
命名空間中的類別、介面和列舉。
PHP
安裝最新版本的用戶端程式庫。詳情請參閱「安裝用戶端程式庫」。
此外,請更新應用程式,使用 Google \ Cloud \ SecurityCenter \ V2
命名空間中的類別和列舉。
Python
安裝最新版本的用戶端程式庫。詳情請參閱「安裝用戶端程式庫」。
此外,請更新應用程式,改用 google.cloud.securitycenter_v2
套件中的類別。
Ruby
安裝最新版本的用戶端程式庫。詳情請參閱「安裝用戶端程式庫」。
此外,請更新應用程式,在建立用戶端物件時,將 version
參數設為 :v2
。
如要以程式輔助方式管理 Security Command Center 內建服務及其啟用狀態,或是管理 Event Threat Detection 或 Security Health Analytics 的自訂模組,您也必須安裝 Security Command Center Management API 的用戶端程式庫,並更新應用程式以使用該用戶端程式庫。