Add predefined organization policies

MySQL  |  PostgreSQL  |  SQL Server

This page describes how to add organization policies on Cloud SQLinstances, to put restrictions on Cloud SQL at the project, folder, ororganization level. For an overview, seeCloud SQL organization policies.

Before you begin

  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.

    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

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

  4. Install thegcloud 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. Toinitialize the gcloud CLI, run the following command:

    gcloudinit
  7. Add theOrganization Policy Administrator role (roles/orgpolicy.policyAdmin) to your user or service account from theIAM & Admin page.

    Go to the IAM accounts page

  8. SeeRestrictions before performing this procedure.

Add the connection organization policy

For an overview seeConnection organization policies.

To add a connection organization policy:

  1. Go to theOrganization policies page.

    Go to the Organization policies page

  2. Click projects dropdown menu in the top tab, and then select the project, folder,or organization that requires the organization policy. TheOrganization policies page displays a list of organization policyconstraints that are available.

  3. Filter for the constraintname ordisplay_name.

    • To disable access to or from the Internet:

      name:"constraints/sql.restrictPublicIp"display_name:"Restrict Public IP access on Cloud SQL instances"
    • To disable access from the internet when IAM authentication is missing(this does not affect access using Private IP):

      name:"constraints/sql.restrictAuthorizedNetworks"display_name:"Restrict Authorized Networks on Cloud SQL instances"
  4. Select the policyName from the list.

  5. ClickEdit.

  6. ClickCustomize.

  7. ClickAdd rule.

  8. UnderEnforcement, clickOn.

  9. ClickSave.

Add the CMEK organization policy

For an overview, seeCustomer-managed encryption keys organization policies.

To add a CMEK organization policy:

  1. Go to theOrganization policies page.

    Go to the Organization policies page

  2. Click projects dropdown menu in the top tab, and then select the project, folder,or organization that requires the organization policy. TheOrganization policies page displays a list of organization policyconstraints that are available.

  3. Filter for the constraintname ordisplay_name.

    • To put service names in a DENY list to ensure that CMEK is used in theresources for that service:

      name:"constraints/gcp.restrictNonCmekServices"display_name:"Restrict which services may create resources without CMEK"

      You must addsqladmin.googleapis.com to the list of restricted serviceswith Deny.

    • To put project IDs in an ALLOW list to ensure that only keys from aninstance of Cloud KMS within that project are used for CMEK.

      name:"constraints/gcp.restrictCmekCryptoKeyProjects"display_name:"Restrict which projects may supply KMS CryptoKeys for CMEK"
  4. Select the policyName from the list.

  5. ClickEdit.

  6. ClickCustomize.

  7. ClickAdd rule.

  8. UnderPolicy values, clickCustom.

  9. Forconstraints/gcp.restrictNonCmekServices:a. UnderPolicy types, selectDeny.b. UnderCustom values, entersqladmin.googleapis.com.

    Forconstraints/gcp.restrictCmekCryptoKeyProjects:a. UnderPolicy types, selectAllow.b. UnderCustom values, enter the resource using the following format:under:organizations/ORGANIZATION_ID,under:folders/FOLDER_ID, orprojects/PROJECT_ID.

  10. ClickDone.

  11. ClickSave.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-14 UTC.