Manage Cloud Load Balancing resources using custom constraints

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

  • compute.googleapis.com/BackendBucket
  • compute.googleapis.com/BackendService
  • compute.googleapis.com/ForwardingRule
  • compute.googleapis.com/HealthCheck
  • compute.googleapis.com/NetworkEndpointGroup
  • networkservices.googleapis.com/ServiceLbPolicy
  • compute.googleapis.com/SslPolicy
  • compute.googleapis.com/TargetInstance
  • compute.googleapis.com/TargetPool
  • compute.googleapis.com/TargetTcpProxy
  • compute.googleapis.com/TargetSslProxy
  • compute.googleapis.com/TargetHttpProxy
  • compute.googleapis.com/TargetHttpsProxy
  • compute.googleapis.com/TargetGrpcProxy
  • compute.googleapis.com/UrlMap

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

  • Cost management: use custom organization policies to restrict the health check probe frequency.
  • Security, compliance, and governance: you can use custom organization policies to enforce policies. For example:

    • To enforce the usage of specific health check protocols or port ranges
    • To disallow certain backend traffic protocols
    • To require that backend buckets have Cloud CDN enabled
    • To require forwarding rules to use specific Network Service Tiers

Limitations

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 init
  7. 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

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

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

Cloud Load Balancing supported resources

For Cloud Load Balancing, you can set custom constraints on the following resources and fields.

Resource Field
compute.googleapis.com/BackendBucket resource.bucketName
resource.cdnPolicy.bypassCacheOnRequestHeaders.headerName
resource.cdnPolicy.cacheKeyPolicy.includeHttpHeaders
resource.cdnPolicy.cacheKeyPolicy.queryStringWhitelist
resource.cdnPolicy.cacheMode
resource.cdnPolicy.clientTtl
resource.cdnPolicy.defaultTtl
resource.cdnPolicy.maxTtl
resource.cdnPolicy.negativeCaching
resource.cdnPolicy.negativeCachingPolicy.code
resource.cdnPolicy.negativeCachingPolicy.ttl
resource.cdnPolicy.requestCoalescing
resource.cdnPolicy.serveWhileStale
resource.cdnPolicy.signedUrlCacheMaxAgeSec
resource.compressionMode
resource.customResponseHeaders
resource.description
resource.enableCdn
resource.loadBalancingScheme
resource.name
compute.googleapis.com/BackendService resource.affinityCookieTtlSec
resource.backends.balancingMode
resource.backends.capacityScaler
resource.backends.description
resource.backends.failover
resource.backends.maxConnections
resource.backends.maxConnectionsPerEndpoint
resource.backends.maxConnectionsPerInstance
resource.backends.maxRate
resource.backends.maxRatePerEndpoint
resource.backends.maxRatePerInstance
resource.backends.maxSessions
resource.backends.maxSessionsPerEndpoint
resource.backends.maxSessionsPerInstance
resource.backends.maxUtilization
resource.backends.preference
resource.backends.trafficDuration
resource.cdnPolicy.bypassCacheOnRequestHeaders.headerName
resource.cdnPolicy.cacheKeyPolicy.includeHost
resource.cdnPolicy.cacheKeyPolicy.includeHttpHeaders
resource.cdnPolicy.cacheKeyPolicy.includeNamedCookies
resource.cdnPolicy.cacheKeyPolicy.includeProtocol
resource.cdnPolicy.cacheKeyPolicy.includeQueryString
resource.cdnPolicy.cacheKeyPolicy.queryStringBlacklist
resource.cdnPolicy.cacheKeyPolicy.queryStringWhitelist
resource.cdnPolicy.cacheMode
resource.cdnPolicy.clientTtl
resource.cdnPolicy.defaultTtl
resource.cdnPolicy.maxTtl
resource.cdnPolicy.negativeCaching
resource.cdnPolicy.negativeCachingPolicy.code
resource.cdnPolicy.negativeCachingPolicy.ttl
resource.cdnPolicy.requestCoalescing
resource.cdnPolicy.serveWhileStale
resource.cdnPolicy.signedUrlCacheMaxAgeSec
resource.circuitBreakers.maxConnections
resource.circuitBreakers.maxPendingRequests
resource.circuitBreakers.maxRequests
resource.circuitBreakers.maxRequestsPerConnection
resource.circuitBreakers.maxRetries
resource.compressionMode
resource.connectionDraining.drainingTimeoutSec
resource.connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends
resource.connectionTrackingPolicy.enableStrongAffinity
resource.connectionTrackingPolicy.idleTimeoutSec
resource.connectionTrackingPolicy.trackingMode
resource.consistentHash.httpCookie.name
resource.consistentHash.httpCookie.path
resource.consistentHash.httpCookie.ttl.nanos
resource.consistentHash.httpCookie.ttl.seconds