本頁說明如何在 Cloud SQL 執行個體上新增組織政策,以便在專案、資料夾或組織層級限制 Cloud SQL。如需總覽,請參閱「Cloud SQL 機構政策」。
事前準備
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Install the gcloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Install the gcloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- 在「IAM 與管理」頁面中,將機構政策管理員角色 (
roles/orgpolicy.policyAdmin
) 新增至使用者或服務帳戶。 - 執行這項程序前,請先參閱「限制」。
前往「Organization policies」(機構政策) 頁面。
按一下頂端分頁中的專案下拉式選單,然後選取需要機構政策的專案、資料夾或機構。「Organization policies」(機構政策) 頁面會顯示可用的機構政策限制條件清單。
篩選限制
name
或display_name
。如要停用網際網路存取權,請按照下列步驟操作:
name: "constraints/sql.restrictPublicIp" display_name: "Restrict Public IP access on Cloud SQL instances"
如要停用來自網際網路的存取權 (這不會影響使用私人 IP 的存取權),請在缺少 IAM 驗證時執行下列操作:
name: "constraints/sql.restrictAuthorizedNetworks" display_name: "Restrict Authorized Networks on Cloud SQL instances"
從清單中選取政策「名稱」。
按一下 [編輯]。
點按「自訂」。
按一下 [新增規則]。
在「強制執行」下方,按一下「開啟」。
按一下 [儲存]。
前往「Organization policies」(機構政策) 頁面。
按一下頂端分頁中的專案下拉式選單,然後選取需要機構政策的專案、資料夾或機構。「Organization policies」(機構政策) 頁面會顯示可用的機構政策限制條件清單。
篩選限制
name
或display_name
。如要將服務名稱加入拒絕清單,確保該服務的資源使用 CMEK,請按照下列步驟操作:
name: "constraints/gcp.restrictNonCmekServices" display_name: "Restrict which services may create resources without CMEK"
您必須在受限制的服務清單中新增
sqladmin.googleapis.com
,並設為「拒絕」。將專案 ID 加入 ALLOW 清單,確保只有該專案中 Cloud KMS 執行個體的金鑰可用於 CMEK。
name: "constraints/gcp.restrictCmekCryptoKeyProjects" display_name: "Restrict which projects may supply KMS CryptoKeys for CMEK"
從清單中選取政策「名稱」。
按一下 [編輯]。
點按「自訂」。
按一下 [新增規則]。
在「政策值」下方,按一下「自訂」。
針對
constraints/gcp.restrictNonCmekServices
: a. 在「政策類型」下方,選取「拒絕」。 b. 在「自訂值」下方輸入sqladmin.googleapis.com
。針對
constraints/gcp.restrictCmekCryptoKeyProjects
: a. 在「政策類型」下方,選取「允許」。 b. 在「自訂值」下方,使用下列格式輸入資源:under:organizations/ORGANIZATION_ID
、under:folders/FOLDER_ID
或projects/PROJECT_ID
。按一下 [完成]。
按一下 [儲存]。
新增連線機構政策
如需總覽,請參閱「連結機構政策」。
如要新增連線機構政策,請按照下列步驟操作:
新增 CMEK 組織政策
如需總覽資訊,請參閱「客戶管理式加密金鑰機構政策」。
如要新增 CMEK 機構政策,請按照下列步驟操作: