本頁面說明如何在 Cloud SQL 執行個體新增組織政策,在專案、資料夾或組織層級對 Cloud SQL 設下限制。如需總覽,請參閱「Cloud SQL 組織政策」。
事前準備
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Install the gcloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - 在「IAM & Admin」(IAM 與管理) 頁面中,將「Organization Policy Administrator」(組織政策管理員) 角色 (
roles/orgpolicy.policyAdmin) 新增至使用者或服務帳戶。 - 執行這項程序前,請先參閱「限制」。
新增連線組織政策
如需總覽,請參閱「連線組織政策」。
如要新增連線組織政策,請按照下列步驟操作:
前往「組織政策」頁面。
按一下頂端分頁中的專案下拉式選單,然後選取需要組織政策的專案、資料夾或組織。「Organization policies」(組織政策) 頁面會顯示可用的組織政策限制清單。
篩選限制
name或display_name。如要停用網際網路存取權或來自網際網路的存取權,請按照下列步驟操作:
name: "constraints/sql.restrictPublicIp" display_name: "Restrict Public IP access on Cloud SQL instances"如要在缺少 IAM 驗證時停用網際網路存取權 (這不會影響使用私人 IP 的存取權):
name: "constraints/sql.restrictAuthorizedNetworks" display_name: "Restrict Authorized Networks on Cloud SQL instances"
從清單中選取政策「名稱」。
按一下 [編輯]。
點按「自訂」。
按一下「Add rule」(新增規則)。
在「Enforcement」(強制執行) 下方,按一下「On」(開啟)。
按一下「儲存」。
新增 CMEK 組織政策
如需總覽,請參閱「客戶自行管理的加密金鑰組織政策」。
如何新增 CMEK 組織政策:
前往「組織政策」頁面。
按一下頂端分頁中的專案下拉式選單,然後選取需要組織政策的專案、資料夾或組織。「Organization policies」(組織政策) 頁面會顯示可用的組織政策限制清單。
篩選限制
name或display_name。如要將服務名稱加入「拒絕」清單,確保該服務的資源使用 CMEK,請按照下列步驟操作:
name: "constraints/gcp.restrictNonCmekServices" display_name: "Restrict which services may create resources without CMEK"您必須將
sqladmin.googleapis.com新增至受限服務清單,並設為「拒絕」。將專案 ID 加入許可清單,確保只有該專案中 Cloud KMS 執行個體的金鑰可用於 CMEK。
name: "constraints/gcp.restrictCmekCryptoKeyProjects" display_name: "Restrict which projects may supply KMS CryptoKeys for CMEK"
從清單中選取政策「名稱」。
按一下 [編輯]。
點按「自訂」。
按一下「Add rule」(新增規則)。
在「Policy values」(政策值) 底下,點選「Custom」(自訂)。
針對
constraints/gcp.restrictNonCmekServices: a. 在「Policy types」(政策類型) 下方,選取「Deny」(拒絕)。 b. 在「Custom values」(自訂值) 下方輸入sqladmin.googleapis.com。針對
constraints/gcp.restrictCmekCryptoKeyProjects: a. 在「Policy types」(政策類型) 下方,選取「Allow」(允許)。 b. 在「Custom values」(自訂值) 下方,使用下列格式輸入資源:under:organizations/ORGANIZATION_ID、under:folders/FOLDER_ID或projects/PROJECT_ID。按一下「完成」。
按一下「儲存」。