Google Cloud 組織政策服務可讓您透過程式輔助,集中控管組織的資源。組織政策管理員可以定義組織政策,也就是一組稱為「限制」的限制,適用於Google Cloud 資源和這些資源在Google Cloud 資源階層中的子系。您可以在組織、資料夾或專案層級強制執行組織政策。
機構政策提供各種Google Cloud 服務的預先定義限制。不過,如要更精細地自訂組織政策中受限的特定欄位,您也可以建立「自訂限制」,並在自訂組織政策中強制執行這些限制。
政策繼承
根據預設,您強制執行政策的資源子系會繼承組織政策。舉例來說,如果您對資料夾強制執行政策, Google Cloud 會對該資料夾中的所有專案強制執行政策。如要進一步瞭解這項行為以及如何變更,請參閱這篇文章。
Google Cloud Armor 支援的資源
對於 Cloud Armor 資源,您可以對下列資源和欄位設定自訂限制。
-
安全性政策:
compute.googleapis.com/SecurityPolicy- 名稱:
resource.name - 說明:
resource.description -
規則:
resource.rules[]-
標頭動作:
resource.rules[].headerAction-
要新增的要求標頭:
resource.rules[].headerAction.requestHeadersToAdds[]-
標頭名稱:
resource.rules[].headerAction.requestHeadersToAdds[].headerName -
標頭值:
resource.rules[].headerAction.requestHeadersToAdds[].headerValue
-
標頭名稱:
-
要新增的要求標頭:
-
比對器:
resource.rules[].match-
版本化運算式:
resource.rules[].match.versionedExpr -
設定:
resource.rules[].match.config-
來源 IP 範圍:
resource.rules[].match.config.srcIpRanges[]
-
來源 IP 範圍:
- 運算式:
resource.rules[].match.expr -
運算式選項:
resource.rules[].match.exprOptions-
reCAPTCHA 選項:
resource.rules[].match.exprOptions.recaptchaOptions-
動作符記網站金鑰:
resource.rules[].match.exprOptions.recaptchaOptions.actionTokenSiteKeys[] -
工作階段符記網站金鑰:
resource.rules[].match.exprOptions.recaptchaOptions.sessionTokenSiteKeys[]
-
動作符記網站金鑰:
-
reCAPTCHA 選項:
-
版本化運算式:
-
聯播網比對工具:
resource.rules[].networkMatch-
使用者定義的欄位相符:
resource.rules[].networkMatch.userDefinedFieldMatch-
名稱:
resource.rules[].networkMatch.userDefinedFieldMatch.name -
值:
resource.rules[].networkMatch.userDefinedFieldMatch.values
-
名稱:
-
來源 IP 範圍:
resource.rules[].networkMatch.srcIpRanges -
目的地 IP 範圍:
resource.rules[].networkMatch.destIpRanges -
IP 通訊協定:
resource.rules[].networkMatch.ipProtocols -
來源通訊埠:
resource.rules[].networkMatch.srcPorts -
目的地通訊埠:
resource.rules[].networkMatch.destPorts -
來源區碼:
resource.rules[].networkMatch.srcRegionCodes -
來源 ASN:
resource.rules[].networkMatch.srcAsns
-
使用者定義的欄位相符:
-
預先設定的 WAF 設定:
resource.rules[].preconfiguredWafConfig-
排除條件:
resource.rules[].preconfiguredWafConfig.exclusions[]-
目標規則集:
resource.rules[].preconfiguredWafConfig.exclusions[].targetRuleSet -
目標規則 ID:
resource.rules[].preconfiguredWafConfig.exclusions[].targetRuleIds[] -
要排除的要求標頭:
resource.rules[].preconfiguredWafConfig.exclusions[].requestHeadersToExclude[]-
值:
resource.rules[].preconfiguredWafConfig.exclusions[].requestHeadersToExclude[].val -
作業:
resource.rules[].preconfiguredWafConfig.exclusions[].requestHeadersToExclude[].op
-
值:
-
要求排除的 Cookie:
resource.rules[].preconfiguredWafConfig.exclusions[].requestCookiesToExclude[]-
值:
resource.rules[].preconfiguredWafConfig.exclusions[].requestCookiesToExclude[].val -
作業:
resource.rules[].preconfiguredWafConfig.exclusions[].requestCookiesToExclude[].op
-
值:
-
要排除的要求查詢參數:
resource.rules[].preconfiguredWafConfig.exclusions[].requestQueryParamsToExclude[]-
值:
resource.rules[].preconfiguredWafConfig.exclusions[].requestQueryParamsToExclude[].val -
作業:
resource.rules[].preconfiguredWafConfig.exclusions[].requestQueryParamsToExclude[].op
-
值:
-
要排除的要求 URI:
resource.rules[].preconfiguredWafConfig.exclusions[].requestUrisToExclude[]-
值:
resource.rules[].preconfiguredWafConfig.exclusions[].requestUrisToExclude[].val -
作業:
resource.rules[].preconfiguredWafConfig.exclusions[].requestUrisToExclude[].op
-
值:
-
目標規則集:
-
排除條件:
-
重新導向選項:
resource.rules[].redirectOptions[]- 類型:
resource.rules[].redirectOptions[].type -
目標:
resource.rules[].redirectOptions[].target
- 類型:
-
頻率限制選項:
resource.rules[].rateLimitOptions[]-
速率限制門檻:
resource.rules[].rateLimitOptions[].rateLimitThreshold-
數量:
resource.rules[].rateLimitOptions[].rateLimitThreshold.count -
間隔秒數:
resource.rules[].rateLimitOptions[].rateLimitThreshold.intervalSec
-
數量:
-
確認動作:
resource.rules[].rateLimitOptions[].conformAction -
超過門檻後的動作:
resource.rules[].rateLimitOptions[].exceedAction -
超過重新導向選項:
resource.rules[].rateLimitOptions[].exceedRedirectOptions-
類型:
resource.rules[].rateLimitOptions[].exceedRedirectOptions.type -
目標:
resource.rules[].rateLimitOptions[].exceedRedirectOptions.target
-
類型:
-
超過門檻後的動作 RPC 狀態:
resource.rules[].rateLimitOptions[].exceedActionRpcStatus-
代碼:
resource.rules[].rateLimitOptions[].exceedActionRpcStatus.code -
訊息:
resource.rules[].rateLimitOptions[].exceedActionRpcStatus.message
-
代碼:
-
對下列金鑰強制執行:
resource.rules[].rateLimitOptions[].enforceOnKey -
強制啟用金鑰名稱:
resource.rules[].rateLimitOptions[].enforceOnKeyName -
強制啟用金鑰設定:
resource.rules[].rateLimitOptions[].enforceOnKeyConfigs-
對下列金鑰類型強制執行:
resource.rules[].rateLimitOptions[].enforceOnKeyConfigs.enforceOnKeyType -
強制啟用金鑰名稱:
resource.rules[].rateLimitOptions[].enforceOnKeyConfigs.enforceOnKeyName
-
對下列金鑰類型強制執行:
-
停權門檻:
resource.rules[].rateLimitOptions[].banThreshold-
數量:
resource.rules[].rateLimitOptions[].banThreshold.count -
間隔秒數:
resource.rules[].rateLimitOptions[].banThreshold.intervalSec
-
數量:
-
停權時間長度 (秒):
resource.rules[].rateLimitOptions[].banDurationSec
-
速率限制門檻:
-
重新導向目標:
resource.rules[].redirectTarget - 規則編號:
resource.rules[].ruleNumber
-
標頭動作:
-
可調整的防護設定:
resource.adaptiveProtectionConfig-
第 7 層分散式阻斷服務防禦設定:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig-
啟用:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.enable -
規則顯示設定:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.ruleVisibility -
門檻設定:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[]-
名稱:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].name -
自動部署載入門檻:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].autoDeployLoadThreshold -
自動部署可信度門檻:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].autoDeployConfidenceThreshold -
自動部署受影響的基準門檻:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].autoDeployImpactedBaselineThreshold -
自動部署期限 (秒):
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].autoDeployExpirationSec -
偵測負載門檻:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].detectionLoadThreshold -
偵測絕對 QPS:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].detectionAbsoluteQps -
偵測到的基準 QPS 倍數:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].detectionRelativeToBaselineQps -
流量精細程度設定:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].trafficGranularityConfigs[]-
類型:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].trafficGranularityConfigs[].type -
值:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].trafficGranularityConfigs[].value -
啟用每個不重複的值:
resource.adaptiveProtectionConfig.layer7DdosDefenseConfig.thresholdConfigs[].trafficGranularityConfigs[].enableEachUniqueValue
-
類型:
-
名稱:
-
啟用:
-
自動部署設定:
resource.adaptiveProtectionConfig.autoDeployConfig-
負載門檻:
resource.adaptiveProtectionConfig.autoDeployConfig.loadThreshold -
可信度門檻:
resource.adaptiveProtectionConfig.autoDeployConfig.confidenceThreshold -
受影響的基準門檻:
resource.adaptiveProtectionConfig.autoDeployConfig.impactedBaselineThreshold -
期限 (秒):
resource.adaptiveProtectionConfig.autoDeployConfig.expirationSec
-
負載門檻:
-
第 7 層分散式阻斷服務防禦設定:
-
進階選項設定:
resource.advancedOptionsConfig-
JSON 剖析:
resource.advancedOptionsConfig.jsonParsing -
JSON 自訂設定:
resource.advancedOptionsConfig.jsonCustomConfig-
內容類型:
resource.advancedOptionsConfig.jsonCustomConfig.contentTypes[]
-
內容類型:
-
記錄層級:
resource.advancedOptionsConfig.logLevel -
使用者 IP 要求標頭:
resource.advancedOptionsConfig.userIpRequestHeaders[]
-
JSON 剖析:
-
分散式阻斷服務防護設定:
resource.ddosProtectionConfig-
DDoS 防護:
resource.ddosProtectionConfig.ddosProtection
-
DDoS 防護:
-
reCAPTCHA 選項設定:
resource.recaptchaOptionsConfig-
重新導向網站金鑰:
resource.recaptchaOptionsConfig.redirectSiteKey
-
重新導向網站金鑰:
- 類型:
resource.type -
使用者定義的欄位:
resource.userDefinedFields[]- 名稱:
resource.userDefinedFields[].name - 底數:
resource.userDefinedFields[].base - 位移:
resource.userDefinedFields[].offset - 大小:
resource.userDefinedFields[].size - 遮罩:
resource.userDefinedFields[].mask
- 名稱:
- 名稱:
-
網路邊緣安全服務:
compute.googleapis.com/NetworkEdgeSecurityService- 名稱:
resource.name - 說明:
resource.description - 安全性政策:
resource.securityPolicy
- 名稱:
定義自訂限制
自訂限制是由您要強制執行機構政策的服務所支援的資源、方法、條件和動作定義。自訂限制的條件是使用一般運算語言 (CEL) 來定義。如要進一步瞭解如何使用 CEL 在自訂限制中建構條件,請參閱「建立及管理組織政策」的 CEL 相關章節。
事前準備
-
如果尚未設定驗證,請先完成設定。
驗證可確認您的身分,以便存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列其中一個選項,向 Compute Engine 進行驗證:
選取這個頁面上您打算如何使用範例的分頁:
控制台
使用 Google Cloud 控制台存取 Google Cloud 服務和 API 時,無須設定驗證。
gcloud
-
安裝 Google Cloud CLI。 完成後,執行下列指令來初始化 Google Cloud CLI:
gcloud init若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
- 設定預設地區和區域。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI。
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」。
必要的角色
如要取得管理 Cloud Armor 資源組織政策所需的權限,請要求管理員授予您下列 IAM 角色:
- 機構資源的機構政策管理員 (
roles/orgpolicy.policyAdmin) -
如要測試限制,請執行下列操作:
- 專案的 Compute 安全管理員 (
roles/compute.securityAdmin) - 專案的服務帳戶使用者 (
roles/iam.serviceAccountUser)
- 專案的 Compute 安全管理員 (
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
這些預先定義的角色具備管理 Cloud Armor 資源組織政策所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:
所需權限
如要管理 Cloud Armor 資源的組織政策,必須具備下列權限:
-
orgpolicy.constraints.list -
orgpolicy.policies.create -
orgpolicy.policies.delete -
orgpolicy.policies.list -
orgpolicy.policies.update -
orgpolicy.policy.get -
orgpolicy.policy.set
設定自訂限制
您可以使用 Google Cloud 控制台或 Google Cloud CLI 建立自訂限制,並設定在機構政策中使用。控制台
前往 Google Cloud 控制台的「Organization policies」(組織政策) 頁面。
選取頁面頂端的「專案挑選器」。
在專案挑選器中,選取要設定組織政策的資源。
按一下「自訂限制」。
在「顯示名稱」方塊中,輸入限制的易記名稱。這個欄位的長度上限為 200 個字元。請勿在限制名稱中輸入個人識別資訊或機密資料,因為錯誤訊息可能會導致上述資訊曝光。
在「Constraint ID」(限制條件 ID) 方塊中,輸入新自訂限制條件的名稱。自訂限制必須以
custom.開頭,且只能包含大/小寫英文字母或數字,例如 custom.requireSecurityPolicyWithStandardJsonParsing。這個欄位的長度上限為 70 個字元,不含前置字元,例如organizations/123456789/customConstraints/custom.。在「說明」方塊中,輸入違反政策時會以錯誤訊息形式顯示且易於理解的限制說明。這個欄位的長度上限為 2,000 個字元。
在「Resource type」(資源類型) 方塊中,選取包含要限制物件和欄位的 Google CloudREST 資源名稱。例如:
compute.googleapis.com/SecurityPolicy。在「強制執行方式」下方,選取要僅對 REST
CREATE方法強制執行限制,還是對 RESTCREATE和UPDATE方法都強制執行限制。如要定義條件,請按一下「編輯條件」。
在「新增條件」面板中,建立參照支援服務資源的 CEL 條件。這個欄位的長度上限為 1,000 個字元。
按一下 [儲存]。
在「動作」下方,選取是否要在符合條件時允許或拒絕評估方法。
按一下「建立限制」。
在每個欄位中輸入值後,右側會顯示這個自訂限制的對等 YAML 設定。
gcloud
如要使用 Google Cloud CLI 建立自訂限制條件,請建立 YAML 檔案。
name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME resource_types