Create custom organization policy constraints

This page shows you how to use Organization Policy Service custom constraints to restrict specific operations on the following Google Cloud resources:

  • dns.googleapis.com/ManagedZone
  • dns.googleapis.com/Policy
  • dns.googleapis.com/ResponsePolicy
  • dns.googleapis.com/ResponsePolicyRule
  • dns.googleapis.com/ResourceRecordSet

To learn more about Organization Policy, see Custom organization policies.

About organization policies and constraints

The Google Cloud Organization Policy Service gives you centralized, programmatic control over your organization's resources. As the organization policy administrator, you can define an organization policy, which is a set of restrictions called constraints that apply to Google Cloud resources and descendants of those resources in the Google Cloud resource hierarchy. You can enforce organization policies at the organization, folder, or project level.

Organization Policy provides built-in managed constraints for various Google Cloud services. However, if you want more granular, customizable control over the specific fields that are restricted in your organization policies, you can also create custom constraints and use those custom constraints in an organization policy.

Policy inheritance

By default, organization policies are inherited by the descendants of the resources on which you enforce the policy. For example, if you enforce a policy on a folder, Google Cloud enforces the policy on all projects in the folder. To learn more about this behavior and how to change it, refer to Hierarchy evaluation rules.

Benefits

You can use custom organization policies to allow or deny specific values for Cloud DNS resources. For example, if a request to create or update a Cloud DNS instance fails to satisfy custom constraint validation as set by your organization policy, the request fails and an error will be returned to the caller.

Limitations

Like all organization policy constraints, policy changes don't apply retroactively to existing instances.

  • A new policy doesn't impact existing instance configurations.
  • An existing instance configuration remains valid, unless you change it from a compliant to non-compliant value using the Google Cloud console, Google Cloud CLI, or RPC.
  • The resource.visibility field for a ManagedZone must be set to one of the allowed values, all in uppercase:
    • PUBLIC
    • PRIVATE

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.

    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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Install the Google Cloud 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