This page shows you how to use Organization Policy Service custom constraints to restrict specific operations on the following Google Cloud resources:
dataform.googleapis.com/CompilationResultdataform.googleapis.com/Folderdataform.googleapis.com/ReleaseConfigdataform.googleapis.com/Repositorydataform.googleapis.com/TeamFolderdataform.googleapis.com/WorkflowConfigdataform.googleapis.com/WorkflowInvocationdataform.googleapis.com/Workspace
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
Dataform resources. For example, if a request to create or update a
dataform.googleapis.com/Repository resource doesn't pass the custom constraint
validation as set by your organization policy, the request fails and an error is
returned to the caller.
The use of custom organization policies adds an additional layer of security, compliance, and governance. For example, you can define policies that allow resource creation only in a particular region, or that forbid using Git remotes outside of your organization.
Limitations
Like all organization policy constraints, policy changes don't apply retroactively to existing resources:
- A new policy doesn't affect existing resources.
- If you change the policy, an existing resource remains valid, unless you change the resource from a compliant to a non-compliant value using the Google Cloud console or an RPC.
We recommend making all existing resources compliant with a policy before enforcing a new policy. To check which existing resources won't be compliant after you enforce a policy, use the Policy Simulator for Organization Policy.
Before you begin
- 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.
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 Google Cloud 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.
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 Google Cloud 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 - Ensure that you know your organization ID.
Required roles
To get the permissions that
you need to manage custom organization policies,
ask your administrator to grant you the
Organization Policy Administrator (roles/orgpolicy.policyAdmin) IAM role on the organization resource.
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
Dataform supported resources
The following table lists the Dataform resources that you can reference in custom constraints.| Resource | Field |
|---|---|
| dataform.googleapis.com/CompilationResult |
resource.codeCompilationConfig.assertionSchema
|
resource.codeCompilationConfig.builtinAssertionNamePrefix
| |
resource.codeCompilationConfig.databaseSuffix
| |
resource.codeCompilationConfig.defaultDatabase
| |
resource.codeCompilationConfig.defaultLocation
| |
resource.codeCompilationConfig.defaultNotebookRuntimeOptions.aiPlatformNotebookRuntimeTemplate
| |
resource.codeCompilationConfig.defaultNotebookRuntimeOptions.gcsOutputBucket
| |
resource.codeCompilationConfig.defaultSchema
| |
resource.codeCompilationConfig.schemaSuffix
| |
resource.codeCompilationConfig.tablePrefix
| |
resource.codeCompilationConfig.vars
| |
resource.gitCommitish
| |
resource.releaseConfig
| |
resource.workspace
| |
| dataform.googleapis.com/Folder |
resource.containingFolder
|
resource.displayName
| |
| dataform.googleapis.com/ReleaseConfig |
resource.codeCompilationConfig.assertionSchema
|
resource.codeCompilationConfig.builtinAssertionNamePrefix
| |
resource.codeCompilationConfig.databaseSuffix
| |
resource.codeCompilationConfig.defaultDatabase
| |
resource.codeCompilationConfig.defaultLocation
| |
resource.codeCompilationConfig.defaultNotebookRuntimeOptions.aiPlatformNotebookRuntimeTemplate
| |
resource.codeCompilationConfig.defaultNotebookRuntimeOptions.gcsOutputBucket
| |
resource.codeCompilationConfig.defaultSchema
| |
resource.codeCompilationConfig.schemaSuffix
| |
resource.codeCompilationConfig.tablePrefix
| |
resource.codeCompilationConfig.vars
| |
resource.cronSchedule
| |
resource.disabled
| |
resource.gitCommitish
| |
resource.name
| |
resource.releaseCompilationResult
| |
resource.timeZone
| |
| dataform.googleapis.com/Repository |
resource.containingFolder
|
resource.displayName
| |
resource.gitRemoteSettings.authenticationTokenSecretVersion
| |
resource.gitRemoteSettings.defaultBranch
| |
resource.gitRemoteSettings.sshAuthenticationConfig.hostPublicKey
| |
resource.gitRemoteSettings.sshAuthenticationConfig.userPrivateKeySecretVersion
| |
resource.gitRemoteSettings.url
| |
resource.kmsKeyName
| |
resource.name
| |
resource.npmrcEnvironmentVariablesSecretVersion
| |
resource.serviceAccount
| |
resource.setAuthenticatedUserAdmin
| |
resource.workspaceCompilationOverrides.defaultDatabase
| |
resource.workspaceCompilationOverrides.schemaSuffix
| |
resource.workspaceCompilationOverrides.tablePrefix
| |
| dataform.googleapis.com/TeamFolder |
resource.displayName
|
| dataform.googleapis.com/WorkflowConfig |
resource.cronSchedule
|
resource.disabled
| |
resource.invocationConfig.fullyRefreshIncrementalTablesEnabled
| |
resource.invocationConfig.includedTags
| |
resource.invocationConfig.includedTargets.database
| |
resource.invocationConfig.includedTargets.name
| |
resource.invocationConfig.includedTargets.schema
| |
resource.invocationConfig.queryPriority
| |
resource.invocationConfig.serviceAccount
| |
resource.invocationConfig.transitiveDependenciesIncluded
| |
resource.invocationConfig.transitiveDependentsIncluded
| |
resource.name
| |
resource.releaseConfig
| |
resource.timeZone
| |
| dataform.googleapis.com/WorkflowInvocation |
resource.compilationResult
|
resource.invocationConfig.fullyRefreshIncrementalTablesEnabled
| |
resource.invocationConfig.includedTags
| |
resource.invocationConfig.includedTargets.database
| |
resource.invocationConfig.includedTargets.name
| |
resource.invocationConfig.includedTargets.schema
| |
resource.invocationConfig.queryPriority
| |
resource.invocationConfig.serviceAccount
| |
resource.invocationConfig.transitiveDependenciesIncluded
| |
resource.invocationConfig.transitiveDependentsIncluded
| |
resource.workflowConfig
| |
| dataform.googleapis.com/Workspace |
resource.name
|
Set up a custom constraint
A custom constraint is defined in a YAML file by the resources, methods, conditions, and actions that are supported by the service on which you are enforcing the organization policy. Conditions for your custom constraints are defined using Common Expression Language (CEL). For more information about how to build conditions in custom constraints using CEL, see the CEL section of Creating and managing custom constraints.
Console
To create a custom constraint, do the following:
- In the Google Cloud console, go to the Organization policies page.
- From the project picker, select the project that you want to set the organization policy for.
- Click Custom constraint.
- In the Display name box, enter a human-readable name for the constraint. This name is used in error messages and can be used for identification and debugging. Don't use personally identifiable information (PII) or sensitive data in display names because this name could be exposed in error messages. This field can contain up to 200 characters.