This page shows you how to use Organization Policy Service custom constraints to restrict specific operations on the following Google Cloud resources:
networkservices.googleapis.com/LbRouteExtensionnetworkservices.googleapis.com/LbTrafficExtension
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 with Service Extensions to do the following:
- Allow only one type of the load balancing scheme
- Disallow certain supported events types
- Restrict the number of extension chains and extensions
Before you begin
-
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 initRequired 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.
Service Extensions supported resources
The following table lists the Service Extensions resources that you can reference in custom constraints.| Resource | Field |
|---|---|
| networkservices.googleapis.com/LbRouteExtension |
resource.description
|
resource.extensionChains.extensions.authority
| |
resource.extensionChains.extensions.failOpen
| |
resource.extensionChains.extensions.forwardHeaders
| |
resource.extensionChains.extensions.metadata
| |
resource.extensionChains.extensions.name
| |
resource.extensionChains.extensions.supportedEvents
| |
resource.extensionChains.extensions.timeout
| |
resource.extensionChains.name
| |
resource.loadBalancingScheme
| |
resource.metadata
| |
resource.name
| |
| networkservices.googleapis.com/LbTrafficExtension |
resource.description
|
resource.extensionChains.extensions.authority
| |
resource.extensionChains.extensions.failOpen
| |
resource.extensionChains.extensions.forwardHeaders
| |
resource.extensionChains.extensions.metadata
| |
resource.extensionChains.extensions.name
| |
resource.extensionChains.extensions.supportedEvents
| |
resource.extensionChains.extensions.timeout
| |
resource.extensionChains.name
| |
resource.loadBalancingScheme
| |
resource.metadata
| |
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.
-
In the Constraint ID box, enter the ID that you want for your new custom
constraint. A custom constraint can only contain letters (including upper and lowercase) or
numbers, for example
custom.LbTrafficExtensionDenyBodyEvents. This field can contain up to 70 characters, not counting the prefix (custom.), for example,organizations/123456789/customConstraints/custom. Don't include PII or sensitive data in your constraint ID, because it could be exposed in error messages. - In the Description box, enter a human-readable description of the constraint. This description is used as an error message when the policy is violated. Include details about why the policy violation occurred and how to resolve the policy violation. Don't include PII or sensitive data in your description, because it could be exposed in error messages. This field can contain up to 2000 characters.
-
In the Resource type box, select the name of the Google Cloud REST resource
containing the object and field that you want to restrict—for example,
container.googleapis.com/NodePool. Most resource types support up to 20 custom constraints. If you attempt to create more custom constraints, the operation fails. - Under Enforcement method, select whether to enforce the constraint on a REST