新增預先定義的機構政策

本頁說明如何在 Cloud SQL 執行個體上新增組織政策,以便在專案、資料夾或組織層級限制 Cloud SQL。如需總覽,請參閱「Cloud SQL 機構政策」。

事前準備

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Install the gcloud CLI.

  5. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init
  7. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  8. Make sure that billing is enabled for your Google Cloud project.

  9. Install the gcloud CLI.

  10. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  11. To initialize the gcloud CLI, run the following command:

    gcloud init
  12. 在「IAM 與管理」頁面中,將機構政策管理員角色 (roles/orgpolicy.policyAdmin) 新增至使用者或服務帳戶。

    前往「IAM 帳戶」頁面

  13. 執行這項程序前,請先參閱「限制」。
  14. 新增連線機構政策

    如需總覽,請參閱「連結機構政策」。

    如要新增連線機構政策,請按照下列步驟操作:

    1. 前往「Organization policies」(機構政策) 頁面。

      前往「Organization policies」(組織政策) 頁面

    2. 按一下頂端分頁中的專案下拉式選單,然後選取需要機構政策的專案、資料夾或機構。「Organization policies」(機構政策) 頁面會顯示可用的機構政策限制條件清單。

    3. 篩選限制 namedisplay_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"
        
    4. 從清單中選取政策「名稱」

    5. 按一下 [編輯]

    6. 點按「自訂」

    7. 按一下 [新增規則]

    8. 在「強制執行」下方,按一下「開啟」

    9. 按一下 [儲存]

    新增 CMEK 組織政策

    如需總覽資訊,請參閱「客戶管理式加密金鑰機構政策」。

    如要新增 CMEK 機構政策,請按照下列步驟操作:

    1. 前往「Organization policies」(機構政策) 頁面。

      前往「Organization policies」(組織政策) 頁面

    2. 按一下頂端分頁中的專案下拉式選單,然後選取需要機構政策的專案、資料夾或機構。「Organization policies」(機構政策) 頁面會顯示可用的機構政策限制條件清單。

    3. 篩選限制 namedisplay_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"
        
    4. 從清單中選取政策「名稱」

    5. 按一下 [編輯]

    6. 點按「自訂」

    7. 按一下 [新增規則]

    8. 在「政策值」下方,按一下「自訂」

    9. 針對 constraints/gcp.restrictNonCmekServices: a. 在「政策類型」下方,選取「拒絕」。 b. 在「自訂值」下方輸入 sqladmin.googleapis.com

      針對 constraints/gcp.restrictCmekCryptoKeyProjects: a. 在「政策類型」下方,選取「允許」。 b. 在「自訂值」下方,使用下列格式輸入資源: under:organizations/ORGANIZATION_IDunder:folders/FOLDER_IDprojects/PROJECT_ID

    10. 按一下 [完成]

    11. 按一下 [儲存]

    後續步驟