Mengelola resource Cloud Load Balancing menggunakan batasan kustom

Kebijakan Organisasi Google Cloud memberi Anda kontrol terpusat dan terprogram atas resource organisasi. Sebagai administrator kebijakan organisasi, Anda dapat menentukan kebijakan organisasi, yang merupakan serangkaian batasan yang disebut batasan yang berlaku untuk resource Google Cloud dan turunan dari resource tersebut di Hierarki resource Google Cloud. Anda dapat menerapkan kebijakan organisasi di level organisasi, folder, atau project.

Kebijakan Organisasi memberikan batasan yang telah ditetapkan untuk berbagai layanan Google Cloud. Namun, jika menginginkan kontrol yang lebih terperinci dan dapat disesuaikan atas kolom tertentu yang dibatasi dalam kebijakan organisasi, Anda juga dapat membuat batasan kustom dan menggunakan batasan kustom tersebut dalam kebijakan organisasi kustom.

Komponen load balancing berikut mendukung batasan kustom:

Manfaat

  • Pengelolaan biaya: gunakan kebijakan organisasi kustom untuk membatasi frekuensi pemeriksaan health check.
  • Keamanan, kepatuhan, dan tata kelola: Anda dapat menggunakan kebijakan organisasi kustom untuk menerapkan kebijakan. Contoh:

    • Untuk menegakkan penggunaan protokol atau rentang port health check tertentu
    • Untuk melarang protokol traffic backend tertentu
    • Untuk mewajibkan bucket backend mengaktifkan Cloud CDN
    • Untuk mewajibkan aturan penerusan menggunakan Network Service Tiers tertentu

Resource yang didukung Cloud Load Balancing

Untuk Cloud Load Balancing, Anda dapat menetapkan batasan khusus pada resource dan kolom berikut.

Bucket backend

Bucket backend: compute.googleapis.com/BackendBucket

  • resource.name
  • resource.description
  • resource.bucketName
  • resource.enableCdn
  • resource.cdnPolicy
    • resource.cdnPolicy.bypassCacheOnRequestHeaders
      • resource.cdnPolicy.bypassCacheOnRequestHeaders.headerName
    • resource.cdnPolicy.cacheKeyPolicy
      • resource.cdnPolicy.cacheKeyPolicy.includeHttpHeaders
      • resource.cdnPolicy.cacheKeyPolicy.queryStringWhitelist
      • resource.cdnPolicy.signedUrlCacheMaxAgeSec
    • resource.compressionMode
    • resource.customResponseHeaders

Layanan backend

Layanan backend: compute.googleapis.com/BackendService

  • resource.name
  • resource.description
  • resource.port
  • resource.portName
  • resource.protocol
  • resource.backends
    • 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.maxUtilization
    • resource.backends.preference
  • resource.enableCDN
  • resource.cdnPolicy
    • resource.cdnPolicy.bypassCacheOnRequestHeaders
      • resource.cdnPolicy.bypassCacheOnRequestHeaders.headerName
    • resource.cdnPolicy.cacheKeyPolicy
      • 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
      • resource.cdnPolicy.negativeCachingPolicy.code
      • resource.cdnPolicy.negativeCachingPolicy.ttl
    • resource.cdnPolicy.requestCoalescing
    • resource.cdnPolicy.serveWhileStale
    • resource.cdnPolicy.signedUrlCacheMaxAgeSec
  • resource.circuitBreakers
    • resource.circuitBreakers.maxConnections
    • resource.circuitBreakers.maxPendingRequests
    • resource.circuitBreakers.maxRequests
    • resource.circuitBreakers.maxRequestsPerConnection
    • resource.circuitBreakers.maxRetries
  • resource.compressionMode
  • resource.connectionDraining
    • resource.connectionDraining.drainingTimeoutSec
  • resource.connectionTrackingPolicy
    • resource.connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends
    • resource.connectionTrackingPolicy.enableStrongAffinity
    • resource.connectionTrackingPolicy.idleTimeoutSec
    • resource.connectionTrackingPolicy.trackingMode
  • resource.consistentHash
    • resource.consistentHash.httpCookie
    • resource.consistentHash.httpCookie.name
    • resource.consistentHash.httpCookie.path
    • resource.consistentHash.httpCookie.ttl
      • resource.consistentHash.httpCookie.ttl.nanos
      • resource.consistentHash.httpCookie.ttl.seconds
    • resource.consistentHash.minimumRingSize
  • resource.customRequestHeaders
  • resource.customResponseHeaders
  • resource.affinityCookieTtlSec
  • resource.failoverPolicy
    • resource.failoverPolicy.disableConnectionDrainOnFailover
    • resource.failoverPolicy.dropTrafficIfUnhealthy
    • resource.failoverPolicy.failoverRatio
  • resource.iap
    • resource.iap.enabled
    • resource.iap.oauth2ClientId
  • resource.ipAddressSelectionPolicy
  • resource.loadBalancingScheme
  • resource.localityLbPolicies
    • resource.localityLbPolicies.customPolicy
    • resource.localityLbPolicies.customPolicy.data
    • resource.localityLbPolicies.customPolicy.name
    • resource.localityLbPolicies.policy
    • resource.localityLbPolicies.policy.name
  • resource.logConfig
    • resource.logConfig.enable
    • resource.logConfig.optionalFields
    • resource.logConfig.optionalMode
    • resource.logConfig.sampleRate
  • resource.maxStreamDuration
    • resource.maxStreamDuration.nanos
    • resource.maxStreamDuration.seconds
  • resource.outlierDetection
    • resource.outlierDetection.baseEjectionTime
    • resource.outlierDetection.baseEjectionTime.nanos
    • resource.outlierDetection.baseEjectionTime.seconds
    • resource.outlierDetection.consecutiveGatewayFailure
    • resource.outlierDetection.enforcingConsecutiveErrors
    • resource.outlierDetection.enforcingConsecutiveGatewayFailure
    • resource.outlierDetection.enforcingSuccessRate
    • resource.outlierDetection.maxEjectionPercent
    • resource.outlierDetection.successRateMinimumHosts
    • resource.outlierDetection.successRateRequestVolume
    • resource.outlierDetection.successRateStdevFactor
  • resource.securitySettings
    • resource.securitySettings.awsV4Authentication
    • resource.securitySettings.awsV4Authentication.accessKeyId
    • resource.securitySettings.awsV4Authentication.accessKeyVersion
    • resource.securitySettings.subjectAltNames
  • resource.sessionAffinity
  • resource.subsetting
    • resource.subsetting.policy
  • resource.timeoutSec
  • resource.strongSessionAffinityCookie
    • resource.strongSessionAffinityCookie.name
    • resource.strongSessionAffinityCookie.path
    • resource.strongSessionAffinityCookie.ttl
    • resource.strongSessionAffinityCookie.ttl.nanos
    • resource.strongSessionAffinityCookie.ttl.seconds

Aturan penerusan

Aturan penerusan: compute.googleapis.com/ForwardingRule

  • resource.name
  • resource.description
  • resource.allowGlobalAccess
  • resource.allowPscGlobalAccess
  • resource.allPorts
  • resource.IPProtocol
  • resource.ipVersion
  • resource.isMirroringCollector
  • resource.loadBalancingScheme
  • resource.metadataFilters
    • resource.metadataFilters.filterLabels
    • resource.metadataFilters.filterLabels.name
    • resource.metadataFilters.filterLabels.value
    • resource.metadataFilters.filterMatchCriteria
  • resource.networkTier
  • resource.noAutomateDnsZone
  • resource.portRange
  • resource.ports
  • resource.serviceDirectoryRegistrations
    • resource.serviceDirectoryRegistrations.namespace
    • resource.serviceDirectoryRegistrations.service
    • resource.serviceDirectoryRegistrations.serviceDirectoryRegion
  • resource.serviceLabel
  • resource.sourceIpRanges

Health check

Pemeriksaan kesehatan: compute.googleapis.com/HealthCheck

  • resource.name
  • resource.description
  • resource.checkIntervalSec
  • resource.timeoutSec
  • resource.unhealthyThreshold
  • resource.healthyThreshold
  • resource.type
  • Health check TCP:
    • resource.tcpHealthCheck.port
    • resource.tcpHealthCheck.request
    • resource.tcpHealthCheck.response
    • resource.tcpHealthCheck.proxyHeader
    • resource.tcpHealthCheck.portSpecification
  • Pemeriksaan kondisi SSL:
    • resource.sslHealthCheck.port
    • resource.sslHealthCheck.request
    • resource.sslHealthCheck.response
    • resource.sslHealthCheck.proxyHeader
    • resource.sslHealthCheck.portSpecification
  • Health check HTTP:
    • resource.httpHealthCheck.port
    • resource.httpHealthCheck.host
    • resource.httpHealthCheck.requestPath
    • resource.httpHealthCheck.proxyHeader
    • resource.httpHealthCheck.response
    • resource.httpHealthCheck.portSpecification
  • Health check HTTPS:
    • resource.httpsHealthCheck.port
    • resource.httpsHealthCheck.host
    • resource.httpsHealthCheck.requestPath
    • resource.httpsHealthCheck.proxyHeader
    • resource.httpsHealthCheck.response
    • resource.httpsHealthCheck.portSpecification
  • Pemeriksaan kesehatan HTTP/2:
    • resource.http2HealthCheck.port
    • resource.http2HealthCheck.host
    • resource.http2HealthCheck.requestPath
    • resource.http2HealthCheck.proxyHeader
    • resource.http2HealthCheck.response
    • resource.http2HealthCheck.portSpecification
  • Health check gRPC:
    • resource.grpcHealthCheck.port
    • resource.grpcHealthCheck.grpcServiceName
    • resource.grpcHealthCheck.portSpecification
  • resource.sourceRegions
  • resource.logConfig
    • resource.logConfig.enable

Proxy target

Target proxy TCP: compute.googleapis.com/TargetTcpProxy

  • resource.name
  • resource.description
  • resource.proxyBind
  • resource.proxyHeader

Target proxy SSL: compute.googleapis.com/TargetSslProxy

  • resource.name
  • resource.description
  • resource.proxyHeader

Proxy HTTP target: compute.googleapis.com/TargetHttpProxy

  • resource.name
  • resource.description
  • resource.proxyBind
  • resource.httpKeepAliveTimeoutSec

Proxy HTTPS target: compute.googleapis.com/TargetHttpsProxy

  • resource.name
  • resource.description
  • resource.proxyBind
  • resource.httpKeepAliveTimeoutSec
  • resource.quicOverride
  • resource.tlsEarlyData

Target proxy gRPC: compute.googleapis.com/TargetGrpcProxy

  • resource.name
  • resource.description
  • resource.validateForProxyless

Peta URL

Peta URL: compute.googleapis.com/UrlMap

  • resource.name
  • resource.description
  • resource.defaultCustomErrorResponsePolicy
    • resource.defaultCustomErrorResponsePolicy.errorResponseRules
      • resource.defaultCustomErrorResponsePolicy.errorResponseRules.matchResponseCodes
      • resource.defaultCustomErrorResponsePolicy.errorResponseRules.overrideResponseCode
      • resource.defaultCustomErrorResponsePolicy.errorResponseRules.path
  • resource.defaultRouteAction
    • resource.defaultRouteAction.corsPolicy
    • resource.defaultRouteAction.corsPolicy.allowCredentials
    • resource.defaultRouteAction.corsPolicy.allowHeaders
    • resource.defaultRouteAction.corsPolicy.allowMethods
    • resource.defaultRouteAction.corsPolicy.allowOrigins
    • resource.defaultRouteAction.corsPolicy.allowOriginRegexes
    • resource.defaultRouteAction.corsPolicy.disabled
    • resource.defaultRouteAction.corsPolicy.exposeHeaders
    • resource.defaultRouteAction.corsPolicy.maxAge
    • resource.defaultRouteAction.faultInjectionPolicy
    • resource.defaultRouteAction.faultInjectionPolicy.abort
      • resource.defaultRouteAction.faultInjectionPolicy.abort.httpStatus
      • resource.defaultRouteAction.faultInjectionPolicy.abort.percentage
    • resource.defaultRouteAction.faultInjectionPolicy.delay
      • resource.defaultRouteAction.faultInjectionPolicy.delay.percentage
      • resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay
      • resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos
      • resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds
    • resource.defaultRouteAction.maxStreamDuration
    • resource.defaultRouteAction.maxStreamDuration.nanos
    • resource.defaultRouteAction.maxStreamDuration.seconds
    • resource.defaultRouteAction.requestMirrorPolicy
    • resource.defaultRouteAction.retryPolicy
    • resource.defaultRouteAction.retryPolicy.numRetries
    • resource.defaultRouteAction.retryPolicy.perTryTimeout
      • resource.defaultRouteAction.retryPolicy.perTryTimeout.nanos
      • resource.defaultRouteAction.retryPolicy.perTryTimeout.seconds
    • resource.defaultRouteAction.retryPolicy.retryConditions
    • resource.defaultRouteAction.timeout
    • resource.defaultRouteAction.timeout.nanos
    • resource.defaultRouteAction.timeout.seconds
    • resource.defaultRouteAction.urlRewrite
    • resource.defaultRouteAction.urlRewrite.hostRewrite
    • resource.defaultRouteAction.urlRewrite.pathPrefixRewrite
    • resource.defaultRouteAction.urlRewrite.pathTemplateRewrite
    • resource.defaultRouteAction.weightedBackendServices
    • resource.defaultRouteAction.weightedBackendServices.headerAction
      • resource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd
      • resource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerName
      • resource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValue
      • resource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.replace
      • resource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToRemove
      • resource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd
      • resource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerName
      • resource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValue
      • resource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.replace
      • resource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToRemove
    • resource.defaultRouteAction.weightedBackendServices.weight
  • resource.defaultUrlRedirect
    • resource.defaultUrlRedirect.hostRedirect
    • resource.defaultUrlRedirect.httpsRedirect
    • resource.defaultUrlRedirect.pathRedirect
    • resource.defaultUrlRedirect.prefixRedirect
    • resource.defaultUrlRedirect.redirectResponseCode
    • resource.defaultUrlRedirect.stripQuery
  • resource.headerAction
    • resource.headerAction.requestHeadersToAdd
    • resource.headerAction.requestHeadersToAdd.headerName
    • resource.headerAction.requestHeadersToAdd.headerValue
    • resource.headerAction.requestHeadersToAdd.replace
    • resource.headerAction.requestHeadersToRemove
    • resource.headerAction.responseHeadersToAdd
    • resource.headerAction.responseHeadersToAdd.headerName
    • resource.headerAction.responseHeadersToAdd.headerValue
    • resource.headerAction.responseHeadersToAdd.replace
    • resource.headerAction.responseHeadersToRemove
  • resource.hostRules
    • resource.hostRules.description
    • resource.hostRules.hosts
    • resource.hostRules.pathMatcher
  • resource.pathMatchers
    • resource.pathMatchers.name
    • resource.pathMatchers.description
    • resource.pathMatchers.defaultCustomErrorResponsePolicy
    • resource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules
      • resource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules.matchResponseCodes
      • resource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules.overrideResponseCode
      • resource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules.path
    • resource.pathMatchers.defaultRouteAction
    • resource.pathMatchers.defaultRouteAction.corsPolicy
      • resource.pathMatchers.defaultRouteAction.corsPolicy.allowCredentials
      • resource.pathMatchers.defaultRouteAction.corsPolicy.allowHeaders
      • resource.pathMatchers.defaultRouteAction.corsPolicy.allowMethods
      • resource.pathMatchers.defaultRouteAction.corsPolicy.allowOrigins
      • resource.pathMatchers.defaultRouteAction.corsPolicy.allowOriginRegexes
      • resource.pathMatchers.defaultRouteAction.corsPolicy.disabled
      • resource.pathMatchers.defaultRouteAction.corsPolicy.exposeHeaders
      • resource.pathMatchers.defaultRouteAction.corsPolicy.maxAge
    • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy
      • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.abort
      • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.abort.httpStatus
      • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.abort.percentage
      • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay
      • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.percentage
      • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay
        • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos
        • resource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds
    • resource.pathMatchers.defaultRouteAction.maxStreamDuration
      • resource.pathMatchers.defaultRouteAction.maxStreamDuration.nanos
      • resource.pathMatchers.defaultRouteAction.maxStreamDuration.seconds
    • resource.pathMatchers.defaultRouteAction.requestMirrorPolicy
    • resource.pathMatchers.defaultRouteAction.retryPolicy
      • resource.pathMatchers.defaultRouteAction.retryPolicy.numRetries
      • resource.pathMatchers.defaultRouteAction.retryPolicy.perTryTimeout
      • resource.pathMatchers.defaultRouteAction.retryPolicy.perTryTimeout.nanos
      • resource.pathMatchers.defaultRouteAction.retryPolicy.perTryTimeout.seconds
      • resource.pathMatchers.defaultRouteAction.retryPolicy.retryConditions
    • resource.pathMatchers.defaultRouteAction.timeout
      • resource.pathMatchers.defaultRouteAction.timeout.nanos
      • resource.pathMatchers.defaultRouteAction.timeout.seconds
    • resource.pathMatchers.defaultRouteAction.urlRewrite
      • resource.pathMatchers.defaultRouteAction.urlRewrite.hostRewrite
      • resource.pathMatchers.defaultRouteAction.urlRewrite.pathPrefixRewrite
      • resource.pathMatchers.defaultRouteAction.urlRewrite.pathTemplateRewrite
    • resource.pathMatchers.defaultRouteAction.weightedBackendServices
      • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction
      • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd
        • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerName
        • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValue
        • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.replace
      • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToRemove
      • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd
        • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerName
        • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValue
        • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.replace
      • resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToRemove
      • resource.pathMatchers.defaultRouteAction.weightedBackendServices.weight
    • resource.pathMatchers.defaultUrlRedirect
    • resource.pathMatchers.defaultUrlRedirect.hostRedirect
    • resource.pathMatchers.defaultUrlRedirect.httpsRedirect
    • resource.pathMatchers.defaultUrlRedirect.pathRedirect
    • resource.pathMatchers.defaultUrlRedirect.prefixRedirect
    • resource.pathMatchers.defaultUrlRedirect.redirectResponseCode
    • resource.pathMatchers.defaultUrlRedirect.stripQuery
    • resource.pathMatchers.headerAction
    • resource.pathMatchers.headerAction.requestHeadersToAdd
    • resource.pathMatchers.headerAction.requestHeadersToAdd.headerName
    • resource.pathMatchers.headerAction.requestHeadersToAdd.headerValue
    • resource.pathMatchers.headerAction.requestHeadersToAdd.replace
    • resource.pathMatchers.headerAction.requestHeadersToRemove
    • resource.pathMatchers.headerAction.responseHeadersToAdd
    • resource.pathMatchers.headerAction.responseHeadersToAdd.headerName
    • resource.pathMatchers.headerAction.responseHeadersToAdd.headerValue
    • resource.pathMatchers.headerAction.responseHeadersToAdd.replace
    • resource.pathMatchers.headerAction.responseHeadersToRemove
    • resource.pathMatchers.pathRules
    • resource.pathMatchers.pathRules.paths
    • resource.pathMatchers.pathRules.customErrorResponsePolicy
      • resource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules
      • resource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules.matchResponseCodes
      • resource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules.overrideResponseCode
      • resource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules.path
    • resource.pathMatchers.pathRules.routeAction
      • resource.pathMatchers.pathRules.routeAction.corsPolicy
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.allowCredentials
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.allowHeaders
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.allowMethods
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.allowOrigins
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.allowOriginRegexes
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.disabled
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.exposeHeaders
      • resource.pathMatchers.pathRules.routeAction.corsPolicy.maxAge
      • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy
      • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.abort
        • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.abort.httpStatus
        • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.abort.percentage
      • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay
        • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.percentage
        • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.fixedDelay
        • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.fixedDelay.nanos
        • resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.fixedDelay.seconds
      • resource.pathMatchers.pathRules.routeAction.maxStreamDuration
      • resource.pathMatchers.pathRules.routeAction.maxStreamDuration.nanos
      • resource.pathMatchers.pathRules.routeAction.maxStreamDuration.seconds
      • resource.pathMatchers.pathRules.routeAction.requestMirrorPolicy
      • resource.pathMatchers.pathRules.routeAction.retryPolicy
      • resource.pathMatchers.pathRules.routeAction.retryPolicy.numRetries
      • resource.pathMatchers.pathRules.routeAction.retryPolicy.perTryTimeout
        • resource.pathMatchers.pathRules.routeAction.retryPolicy.perTryTimeout.nanos
        • resource.pathMatchers.pathRules.routeAction.retryPolicy.perTryTimeout.seconds
      • resource.pathMatchers.pathRules.routeAction.retryPolicy.retryConditions
      • resource.pathMatchers.pathRules.routeAction.timeout
      • resource.pathMatchers.pathRules.routeAction.timeout.nanos
      • resource.pathMatchers.pathRules.routeAction.timeout.seconds
      • resource.pathMatchers.pathRules.routeAction.urlRewrite
      • resource.pathMatchers.pathRules.routeAction.urlRewrite.hostRewrite
      • resource.pathMatchers.pathRules.routeAction.urlRewrite.pathPrefixRewrite
      • resource.pathMatchers.pathRules.routeAction.urlRewrite.pathTemplateRewrite
      • resource.pathMatchers.pathRules.routeAction.weightedBackendServices
      • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerName
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValue
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.replace
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToRemove
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerName
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValue
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.replace
        • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToRemove
      • resource.pathMatchers.pathRules.routeAction.weightedBackendServices.weight
    • resource.pathMatchers.pathRules.urlRedirect
      • resource.pathMatchers.pathRules.urlRedirect.hostRedirect
      • resource.pathMatchers.pathRules.urlRedirect.httpsRedirect
      • resource.pathMatchers.pathRules.urlRedirect.pathRedirect
      • resource.pathMatchers.pathRules.urlRedirect.prefixRedirect
      • resource.pathMatchers.pathRules.urlRedirect.redirectResponseCode
      • resource.pathMatchers.pathRules.urlRedirect.stripQuery
    • resource.pathMatchers.routeRules
    • resource.pathMatchers.routeRules.description
    • resource.pathMatchers.routeRules.priority
    • resource.pathMatchers.routeRules.customErrorResponsePolicy
      • resource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules
      • resource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules.matchResponseCodes
      • resource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules.overrideResponseCode
      • resource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules.path
    • resource.pathMatchers.routeRules.headerAction
      • resource.pathMatchers.routeRules.headerAction.requestHeadersToAdd
      • resource.pathMatchers.routeRules.headerAction.requestHeadersToAdd.headerName
      • resource.pathMatchers.routeRules.headerAction.requestHeadersToAdd.headerValue
      • resource.pathMatchers.routeRules.headerAction.requestHeadersToAdd.replace
      • resource.pathMatchers.routeRules.headerAction.requestHeadersToRemove
      • resource.pathMatchers.routeRules.headerAction.responseHeadersToAdd
      • resource.pathMatchers.routeRules.headerAction.responseHeadersToAdd.headerName
      • resource.pathMatchers.routeRules.headerAction.responseHeadersToAdd.headerValue
      • resource.pathMatchers.routeRules.headerAction.responseHeadersToAdd.replace
      • resource.pathMatchers.routeRules.headerAction.responseHeadersToRemove
    • resource.pathMatchers.routeRules.matchRules
      • resource.pathMatchers.routeRules.matchRules.fullPathMatch
      • resource.pathMatchers.routeRules.matchRules.headerMatches
      • resource.pathMatchers.routeRules.matchRules.headerMatches.exactMatch
      • resource.pathMatchers.routeRules.matchRules.headerMatches.headerName
      • resource.pathMatchers.routeRules.matchRules.headerMatches.invertMatch
      • resource.pathMatchers.routeRules.matchRules.headerMatches.prefixMatch
      • resource.pathMatchers.routeRules.matchRules.headerMatches.presentMatch
      • resource.pathMatchers.routeRules.matchRules.headerMatches.rangeMatch
        • resource.pathMatchers.routeRules.matchRules.headerMatches.rangeMatch.rangeStart
        • resource.pathMatchers.routeRules.matchRules.headerMatches.rangeMatch.rangeEnd
      • resource.pathMatchers.routeRules.matchRules.headerMatches.regexMatch
      • resource.pathMatchers.routeRules.matchRules.headerMatches.suffixMatch
      • resource.pathMatchers.routeRules.matchRules.ignoreCase
      • resource.pathMatchers.routeRules.matchRules.metadataFilters
      • resource.pathMatchers.routeRules.matchRules.metadataFilters.filterLabels
        • resource.pathMatchers.routeRules.matchRules.metadataFilters.filterLabels.name
        • resource.pathMatchers.routeRules.matchRules.metadataFilters.filterLabels.value
      • resource.pathMatchers.routeRules.matchRules.metadataFilters.filterMatchCriteria
      • resource.pathMatchers.routeRules.matchRules.pathTemplateMatch
      • resource.pathMatchers.routeRules.matchRules.prefixMatch
      • resource.pathMatchers.routeRules.matchRules.queryParameterMatches
      • resource.pathMatchers.routeRules.matchRules.queryParameterMatches.name
      • resource.pathMatchers.routeRules.matchRules.queryParameterMatches.exactMatch
      • resource.pathMatchers.routeRules.matchRules.queryParameterMatches.presentMatch
      • resource.pathMatchers.routeRules.matchRules.queryParameterMatches.regexMatch
      • resource.pathMatchers.routeRules.matchRules.regexMatch
    • resource.pathMatchers.routeRules.routeAction
      • resource.pathMatchers.routeRules.routeAction.corsPolicy
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.allowCredentials
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.allowHeaders
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.allowMethods
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.allowOrigins
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.allowOriginRegexes
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.disabled
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.exposeHeaders
      • resource.pathMatchers.routeRules.routeAction.corsPolicy.maxAge
      • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy
      • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.abort
        • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.abort.httpStatus
        • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.abort.percentage
      • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay
        • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.percentage
        • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.fixedDelay
        • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.fixedDelay.nanos
        • resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.fixedDelay.seconds
      • resource.pathMatchers.routeRules.routeAction.maxStreamDuration
      • resource.pathMatchers.routeRules.routeAction.maxStreamDuration.nanos
      • resource.pathMatchers.routeRules.routeAction.maxStreamDuration.seconds
      • resource.pathMatchers.routeRules.routeAction.requestMirrorPolicy
      • resource.pathMatchers.routeRules.routeAction.retryPolicy
      • resource.pathMatchers.routeRules.routeAction.retryPolicy.numRetries
      • resource.pathMatchers.routeRules.routeAction.retryPolicy.perTryTimeout
        • resource.pathMatchers.routeRules.routeAction.retryPolicy.perTryTimeout.nanos
        • resource.pathMatchers.routeRules.routeAction.retryPolicy.perTryTimeout.seconds
      • resource.pathMatchers.routeRules.routeAction.retryPolicy.retryConditions
      • resource.pathMatchers.routeRules.routeAction.timeout
      • resource.pathMatchers.routeRules.routeAction.timeout.nanos
      • resource.pathMatchers.routeRules.routeAction.timeout.seconds
      • resource.pathMatchers.routeRules.routeAction.urlRewrite
      • resource.pathMatchers.routeRules.routeAction.urlRewrite.hostRewrite
      • resource.pathMatchers.routeRules.routeAction.urlRewrite.pathPrefixRewrite
      • resource.pathMatchers.routeRules.routeAction.urlRewrite.pathTemplateRewrite
      • resource.pathMatchers.routeRules.routeAction.weightedBackendServices
      • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerName
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValue
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.replace
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToRemove
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerName
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValue
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.replace
        • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToRemove
      • resource.pathMatchers.routeRules.routeAction.weightedBackendServices.weight
    • resource.pathMatchers.routeRules.urlRedirect
      • resource.pathMatchers.routeRules.urlRedirect.hostRedirect
      • resource.pathMatchers.routeRules.urlRedirect.httpsRedirect
      • resource.pathMatchers.routeRules.urlRedirect.pathRedirect
      • resource.pathMatchers.routeRules.urlRedirect.prefixRedirect
      • resource.pathMatchers.routeRules.urlRedirect.redirectResponseCode
      • resource.pathMatchers.routeRules.urlRedirect.stripQuery
  • resource.tests
    • resource.tests.description
    • resource.tests.expectedOutputUrl
    • resource.tests.expectedRedirectResponseCode
    • resource.tests.headers
    • resource.tests.headers.name
    • resource.tests.headers.value
    • resource.tests.host
    • resource.tests.path

Kebijakan SSL

Kebijakan SSL: compute.googleapis.com/SslPolicy

  • resource.profile
  • resource.name
  • resource.description
  • resource.minTlsVersion
  • resource.customFeatures

Instance Target

Instance target: compute.googleapis.com/TargetInstance

  • resource.name
  • resource.description
  • resource.natPolicy

Kumpulan target

Target pool: compute.googleapis.com/TargetPool

  • resource.name
  • resource.description
  • resource.sessionAffinity
  • resource.failoverRatio

Untuk resource komputasi lain yang didukung, lihat halaman batasan kustom Compute Engine untuk mengetahui detailnya.

Pewarisan kebijakan

Secara default, kebijakan organisasi diwarisi oleh turunan resource tempat Anda menerapkan kebijakan tersebut. Misalnya, jika Anda menerapkan kebijakan pada folder, Google Cloud akan menerapkan kebijakan tersebut pada semua project di folder tersebut. Untuk mempelajari lebih lanjut perilaku ini dan cara mengubahnya, lihat Aturan evaluasi hierarki.

Sebelum memulai

  • Jika Anda belum melakukannya, siapkan autentikasi. Autentikasi adalah proses verifikasi identitas Anda untuk mengakses layanan dan API Google Cloud. Untuk menjalankan kode atau contoh dari lingkungan pengembangan lokal, Anda dapat mengautentikasi ke Compute Engine dengan memilih salah satu opsi berikut:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.

Peran yang diperlukan

Untuk mendapatkan izin yang Anda perlukan untuk mengelola kebijakan organisasi untuk resource Cloud Load Balancing, minta administrator Anda untuk memberi Anda peran IAM berikut:

Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

Peran yang telah ditetapkan ini berisi izin yang diperlukan untuk mengelola kebijakan organisasi untuk resource Cloud Load Balancing. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:

Izin yang diperlukan

Izin berikut diperlukan untuk mengelola kebijakan organisasi untuk resource Cloud Load Balancing:

  • orgpolicy.constraints.list
  • orgpolicy.policies.create
  • orgpolicy.policies.delete
  • orgpolicy.policies.list
  • orgpolicy.policies.update
  • orgpolicy.policy.get
  • orgpolicy.policy.set

Anda mungkin juga bisa mendapatkan izin ini dengan peran khusus atau peran bawaan lainnya.

Menyiapkan batasan kustom

Batasan kustom ditentukan oleh resource, metode, kondisi, dan tindakan yang didukung oleh layanan tempat Anda menerapkan kebijakan organisasi. Kondisi untuk batasan kustom Anda ditentukan menggunakan Common Expression Language (CEL). Untuk mengetahui informasi selengkapnya tentang cara membuat kondisi dalam batasan kustom menggunakan CEL, lihat bagian CEL tentang Membuat dan mengelola kebijakan organisasi kustom.

Anda dapat membuat batasan khusus dan menyiapkannya untuk digunakan dalam kebijakan organisasi menggunakan konsol Google Cloud atau gcloud CLI.

Konsol

  1. Di konsol Google Cloud, buka halaman Organization policies.

    Buka Organization policies

  2. Pilih pemilih project di bagian atas halaman.

  3. Dari jendela Select a resource, pilih organisasi yang ingin Anda buatkan batasan kustom.

  4. Klik Custom constraint.

  5. Di kotak Display name, masukkan nama yang mudah dipahami manusia untuk batasan. Kolom ini memiliki panjang maksimal 200 karakter. Jangan menggunakan PII atau data sensitif dalam nama batasan, karena dapat terekspos dalam pesan error.

  6. Di kotak Constraint ID, masukkan nama yang diinginkan untuk batasan kustom baru. Batasan kustom harus diawali dengan custom., dan hanya dapat menyertakan huruf besar, huruf kecil, atau angka, misalnya, custom.enforceTCPHealthCheckPort1024. Panjang maksimum kolom ini adalah 70 karakter, tidak menghitung awalan, misalnya, organizations/123456789/customConstraints/custom..

  7. Di kotak Description, masukkan deskripsi batasan yang mudah dipahami untuk ditampilkan sebagai pesan error saat kebijakan dilanggar. Kolom ini memiliki panjang maksimal 2000 karakter.

  8. Di kotak Resource type, pilih nama resource REST Google Cloud yang berisi objek dan kolom yang ingin dibatasi. Contoh, compute.googleapis.com/HealthCheck.

  9. Di bagian Enforcement method, pilih apakah akan menerapkan batasan pada metode CREATE REST.

  10. Untuk menentukan kondisi, klik Edit condition.

    1. Di panel Add condition, buat kondisi CEL yang mengacu pada resource layanan yang didukung, misalnya resource.tcpHealthCheck.port >= 1024. Kolom ini memiliki panjang maksimal 1000 karakter.

    2. Klik Simpan.

  11. Di bagian Action, pilih apakah akan mengizinkan atau menolak metode yang dievaluasi jika kondisi sebelumnya terpenuhi.

  12. Klik Create constraint.

Setelah Anda memasukkan nilai ke setiap kolom, konfigurasi YAML yang setara untuk batasan kustom ini akan muncul di sebelah kanan.

gcloud

Untuk membuat batasan khusus menggunakan gcloud CLI, buat file YAML untuk batasan kustom:

name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
resource_types:
- compute.googleapis.com/RESOURCE_NAME
method_types:
- CREATE
- UPDATE
condition: CONDITION
action_type: ACTION
display_name: DISPLAY_NAME
description: DESCRIPTION

Ganti kode berikut:

  • ORGANIZATION_ID: ID organisasi Anda, seperti 123456789.

  • CONSTRAINT_NAME: nama yang Anda inginkan untuk batasan kustom baru. Batasan kustom harus dimulai dengan custom., dan hanya dapat menyertakan huruf besar, huruf kecil, atau angka. Contohnya, custom.enforceTCPHealthCheckPort1024. Panjang maksimum kolom ini adalah 70 karakter, tidak menghitung awalan (misalnya, organizations/123456789/customConstraints/custom.).

  • RESOURCE_NAME: nama (bukan URI) resource REST Compute Engine API yang berisi objek dan kolom yang ingin Anda batasi. Contoh, HealthCheck.

  • CONDITION: kondisi CEL yang ditulis berdasarkan representasi resource layanan yang didukung. Kolom ini memiliki panjang maksimal 1000 karakter. Lihat Resource yang didukung untuk mengetahui informasi selengkapnya tentang resource yang tersedia untuk menulis kondisi. Contoh, "resource.tcpHealthCheck.port >= 1024"

  • ACTION: tindakan yang akan diambil jika condition terpenuhi. Ini dapat berupa ALLOW atau DENY.

  • DISPLAY_NAME: nama yang mudah dibaca manusia untuk batasan. Kolom ini memiliki panjang maksimal 200 karakter.

  • DESCRIPTION: deskripsi batasan yang mudah dipahami untuk ditampilkan sebagai pesan error saat kebijakan dilanggar. Kolom ini memiliki panjang maksimal 2000 karakter.

Untuk mengetahui informasi selengkapnya tentang cara membuat batasan kustom, lihat Membuat dan mengelola kebijakan organisasi kustom.

Setelah membuat file YAML untuk batasan khusus baru, Anda harus menyiapkannya agar tersedia untuk kebijakan organisasi di organisasi Anda. Untuk menyiapkan batasan kustom, gunakan perintah gcloud org-policies set-custom-constraint:
gcloud org-policies set-custom-constraint CONSTRAINT_PATH
Ganti CONSTRAINT_PATH dengan jalur lengkap ke file batasan kustom Anda. Contohnya, /home/user/customconstraint.yaml Setelah selesai, batasan khusus Anda akan tersedia sebagai kebijakan organisasi dalam daftar kebijakan organisasi Google Cloud Anda. Untuk memverifikasi bahwa ada batasan kustom, gunakan perintah gcloud org-policies list-custom-constraints:
gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID
Ganti ORGANIZATION_ID dengan ID fasilitas organisasi Anda. Untuk mengetahui informasi selengkapnya, lihat Melihat kebijakan organisasi.

Menerapkan batasan khusus

Anda dapat menerapkan batasan boolean dengan membuat kebijakan organisasi yang mereferensikannya, lalu menerapkan kebijakan organisasi tersebut ke resource Google Cloud.

Konsol

  1. Di konsol Google Cloud, buka halaman Organization policies.

    Buka Organization policies

  2. Dari pemilih project, pilih project yang ingin Anda tetapkan kebijakan organisasinya.
  3. Dari daftar di halaman Organization policies, pilih batasan untuk melihat halaman Policy details untuk batasan tersebut.
  4. Untuk mengonfigurasi kebijakan organisasi untuk resource ini, klik Manage policy.
  5. Di halaman Edit policy, pilih Override parent's policy.
  6. Klik Add a rule.
  7. Di bagian Enforcement, pilih apakah penerapan kebijakan organisasi ini diaktifkan atau dinonaktifkan.
  8. Opsional: Untuk membuat kebijakan organisasi bersyarat pada tag, klik Add condition. Perhatikan bahwa jika menambahkan aturan kondisional ke kebijakan organisasi, Anda harus menambahkan setidaknya satu aturan tanpa syarat atau kebijakan tidak dapat disimpan. Untuk mengetahui informasi selengkapnya, lihat Menetapkan kebijakan organisasi dengan tag.
  9. Jika ini adalah batasan kustom, Anda dapat mengklik Uji perubahan untuk menyimulasikan efek kebijakan organisasi ini. Untuk mengetahui informasi selengkapnya, lihat Menguji perubahan kebijakan organisasi dengan Policy Simulator.
  10. Untuk menyelesaikan dan menerapkan kebijakan organisasi, klik Set policy. Kebijakan ini memerlukan waktu hingga 15 menit untuk diterapkan.

gcloud

Untuk membuat kebijakan organisasi yang menerapkan batasan boolean, buat file YAML kebijakan yang merujuk batasan tersebut:

      name: projects/PROJECT_ID/policies/CONSTRAINT_NAME
      spec:
        rules:
        - enforce: true
    

Ganti kode berikut:

  • PROJECT_ID: project tempat Anda ingin menerapkan batasan.
  • CONSTRAINT_NAME: nama yang Anda tentukan untuk batasan kustom. Contoh, custom.enforceTCPHealthCheckPort1024

Untuk menerapkan kebijakan organisasi yang berisi batasan, jalankan perintah berikut:

    gcloud org-policies set-policy POLICY_PATH
    

Ganti POLICY_PATH dengan jalur lengkap ke file YAML kebijakan organisasi Anda. Kebijakan ini memerlukan waktu hingga 15 menit untuk diterapkan.

Contoh: Menggunakan batasan kustom untuk membatasi kemampuan TLS

Untuk membatasi kemampuan TLS bagi load balancer yang didukung menggunakan batasan kustom, tentukan kebijakan yang menggunakan batasan constraints/compute.requireSslPolicy yang telah ditentukan sebelumnya di organisasi Anda. Setelah menentukan kebijakan, ikuti langkah-langkah berikut untuk menyiapkan batasan kustom dan menggunakannya.

  1. Buat file YAML untuk batasan yang telah ditentukan sebelumnya.

    name: organizations/ORGANIZATION_ID/customConstraints/custom.CONSTRAINT_NAME
    resource_types: compute.googleapis.com/SslPolicy
    methodTypes:
    - CREATE
    - UPDATE
    condition: resource.FIELD_NAME == VALUE
    action_type: ACTION
    display_name: DISPLAY_NAME
    description: DESCRIPTION
    

    Contoh berikut membatasi versi TLS minimum ke 1.2:

    name: organizations/012345678901/customConstraints/custom.restrictLbTlsVersion
    resource_types: compute.googleapis.com/SslPolicy
    methodTypes:
    - CREATE
    - UPDATE
    condition: resource.minTlsVersion == "TLS_1_2"
    action_type: ALLOW
    display_name: Restrict Load Balancing TLS version to 1.2
    description: Only allow SSL policies to be created or updated if the minimum TLS version is 1.2 where this custom constraint is enforced.
    
  2. Tambahkan batasan kustom ke organisasi Anda.

    gcloud org-policies set-custom-constraint PATH_TO_FILE
    
  3. Pastikan batasan khusus ada di organisasi Anda.

    gcloud org-policies list-custom-constraints \
        --organization=ORGANIZATION_ID
    
  4. Buat file kebijakan untuk batasan.

    name: projects/PROJECT_ID/policies/custom.CONSTRAINT_NAME
    spec:
      rules:
    enforce: true

    Ganti kode berikut:

    • PROJECT_ID: project ID Google Cloud Anda
    • CONSTRAINT_NAME: nama batasan
  5. Terapkan kebijakan.

    gcloud org-policies set-policy PATH_TO_POLICY_FILE
    

    Ganti PATH_TO_POLICY_FILE dengan jalur yang sepenuhnya memenuhi syarat ke file kebijakan Anda.

  6. Dengan asumsi Anda telah membuat file YAML untuk membatasi versi TLS minimum ke 1.2, uji batasan dengan membuat kebijakan SSL dengan minTlsVersion ditetapkan ke TLS_1_0:

    gcloud compute ssl-policies create SSL_POLICY_NAME \
        --min-tls-version=1.0 \
        --project=PROJECT_ID
    

    Outputnya mirip dengan hal berikut ini:

    ERROR: (gcloud.compute.ssl-policies.update) HTTPError 412: Operation
    denied by custom org policy: [customConstraints/custom.
    restrictLbTlsVersion] : Only allow SSL policy resources to be created or
    updated if the minimum TLS version is 1.2 where this custom constraint
    is enforced.
    

Contoh: Membuat batasan yang membatasi port health check TCP minimal 1024

Contoh berikut membuat batasan dan kebijakan kustom yang membatasi nomor port health check TCP minimal 1024.

Sebelum memulai, Anda perlu mengetahui hal-hal berikut:

  • ID organisasi Anda
  • Project ID

gcloud

  1. Buat file batasan enforceTCPHealthCheckPort1024.yaml dengan informasi berikut:

    name: organizations/ORGANIZATION_ID/customConstraints/custom.enforceTCPHealthCheckPort1024
    resource_types: compute.googleapis.com/HealthCheck
    condition: "resource.tcpHealthCheck.port >= 1024"
    method_types: CREATE UPDATE
    action_type: ALLOW
    display_name: Only TCP HealthCheck Port >= 1024 Allowed.
    description: Prevent TCP health checks on well-known ports.
  2. Menetapkan batasan kustom.

    gcloud org-policies set-custom-constraint enforceTCPHealthCheckPort1024.yaml
    
  3. Buat file kebijakan enforceTCPHealthCheckPort1024-policy.yaml dengan informasi berikut. Dalam contoh ini, kami menerapkan batasan ini di level project, tetapi Anda juga dapat menetapkannya di level organisasi atau folder. Ganti PROJECT_ID dengan project ID Anda.

    name: projects/PROJECT_ID/policies/custom.enforceTCPHealthCheckPort1024
    spec:
      rules:
    enforce: true
  4. Terapkan kebijakan.

    gcloud org-policies set-policy enforceTCPHealthCheckPort1024-policy.yaml
    
  5. Uji batasan dengan mencoba membuat health check TCP di port 80, yang tidak diizinkan.

    gcloud compute health-checks create tcp my-tcp-health-check \
        --project=PROJECT_ID \
        --region=us-central1 \
        --port=80 \
        --check-interval=5s \
        --timeout=5s \
        --healthy-threshold=4 \
        --unhealthy-threshold=5 \
    
    

    Outputnya mirip dengan hal berikut ini:

    ERROR: (gcloud.compute.healthChecks.create) Could not fetch resource:
    – Operation denied by custom org policies: [customConstraints/custom.enforceTCPHealthCheckPort1024]: Only TCP HealthCheck Port >= 1024 Allowed.
    

Contoh lainnya untuk kasus penggunaan umum

Bagian berikut memberikan sintaksis untuk beberapa batasan khusus yang mungkin berguna bagi Anda:

Bucket backend

Kasus penggunaan Sintaks
Mewajibkan semua bucket backend untuk mengaktifkan Cloud CDN
name: organizations/ORGANIZATION_ID/customConstraints/custom.backendBucketEnableCdn
resourceTypes:
- compute.googleapis.com/BackendBucket
methodTypes:
- CREATE
- UPDATE
condition: "resource.enableCdn == true"
actionType: ALLOW
displayName: Require all backend buckets to have Cloud CDN enabled
description: All backend buckets must have Cloud CDN enabled.

Layanan backend

Kasus penggunaan Sintaks
Tidak mengizinkan penggunaan HTTP dan TCP sebagai protokol layanan backend
name: organizations/ORGANIZATION_ID/customConstraints/custom.backendBucketEnableCdn
resourceTypes:
- compute.googleapis.com/BackendService
methodTypes:
- CREATE
- UPDATE
condition: "resource.serviceProtocol == 'HTTP' || resource.serviceProtocol == 'TCP'"
actionType: DENY
displayName: Disallow the use of HTTP and TCP as backend service protocols
description: Backend services cannot configure HTTP or TCP as the backend service protocol.

Aturan penerusan

Kasus penggunaan Sintaks
Mewajibkan aturan penerusan untuk menggunakan Paket Standar
name: organizations/ORGANIZATION_ID/customConstraints/custom.forwardingRulesStandardTier
resourceTypes:
- compute.googleapis.com/ForwardingRule
methodTypes:
- CREATE
- UPDATE
condition: "resource.networkTier == 'STANDARD'"
actionType: ALLOW
displayName: Require forwarding rules to use Standard Tier
description: Forwarding rules must use the Standard Network Service Tier.

Health check

Kasus penggunaan Sintaks
Mewajibkan semua protokol health check terjadi di port 1024 atau yang lebih tinggi
name: organizations/ORGANIZATION_ID/customConstraints/custom.healthCheckPortMin1024
resourceTypes:
- compute.googleapis.com/HealthCheck
methodTypes:
- CREATE
- UPDATE
condition: "resource.tcpHealthCheck.port >= 1024 && resource.httpHealthCheck.port >= 1024 && resource.httpsHealthCheck.port >= 1024 && resource.sslHealthCheck.port >= 1024 && resource.sslHealthCheck.port >= 1024 &&resource.http2HealthCheck.port >= 1024 && resource.grpcHealthCheck.port >= 1024"
actionType: ALLOW
displayName: Require port 1024 or greater for all health checks
description: All health check protocols must use a port of 1024 or higher, to avoid well-known ports.
Tidak mengizinkan health check GRPC
name: organizations/ORGANIZATION_ID/customConstraints/custom.disallowGRPCHealthChecks
resourceTypes:
- compute.googleapis.com/HealthCheck
methodTypes:
- CREATE
- UPDATE
condition: "resource.type == 'GRPC'"
actionType: DENY
displayName: Disallow GRPC health checks
description: Health checks aren't allowed to use GRPC.
Mencegah pemeriksaan health check frekuensi tinggi
name: organizations/ORGANIZATION_ID/customConstraints/custom.minHealthCheckFrequency
resourceTypes:
- compute.googleapis.com/HealthCheck
methodTypes:
- CREATE
- UPDATE
condition: "resource.checkIntervalSec >= 30"
actionType: ALLOW
displayName: Disallow fast health check probes
description: Prevent health checks from having a probe frequency under 30 seconds.

Proxy target

Kasus penggunaan Sintaks
Tidak mengizinkan nilai waktu tunggu keepalive HTTPS klien yang lebih besar dari 1.000 detik
name: organizations/ORGANIZATION_ID/customConstraints/custom.clientHTTPSKeepalive1000Sec
resourceTypes:
- compute.googleapis.com/TargetHttpsProxy
methodTypes:
- CREATE
- UPDATE
condition: "resource.httpKeepAliveTimeoutSec > 1000"
actionType: DENY
displayName: Disallow client HTTPS keepalive timeout greater than 1000 seconds
description: Disallow client HTTPS keepalive timeout values greater than 1000 seconds.

Peta URL

Kasus penggunaan Sintaks
Mewajibkan peta URL memiliki kebijakan respons error kustom untuk kode status HTTP 500
name: organizations/ORGANIZATION_ID/customConstraints/custom.urlMapCustomResponseHTTP500
resourceTypes:
- compute.googleapis.com/UrlMaps
methodTypes:
- CREATE
- UPDATE
condition: "resource.defaultCustomErrorResponsePolicy.errorResponseRule.exists(value, value.matchResponseCode == 500)"
actionType: ALLOW
displayName: Require URL maps to have a custom error response policy for HTTP 500 errors
description: URL maps must have a custom error response policy configured for HTTP 500 errors.

Instance Target

Kasus penggunaan Sintaks
Mewajibkan instance target memiliki nama yang diawali dengan string "targetInstance"
name: organizations/ORGANIZATION_ID/customConstraints/custom.targetInstanceConstraint
resourceTypes:
- compute.googleapis.com/TargetInstance
methodTypes:
- CREATE
- UPDATE
condition: "resource.name.startsWith('targetInstance')"
actionType: ALLOW
displayName: Require target instances to have a name that starts with the string "targetInstance"
description: Target instances must have resource names that start with the string "targetInstance"

Kumpulan target

Kasus penggunaan Sintaks
Memerlukan target pool untuk memiliki afinitas sesi CLIENT_IP
name: organizations/ORGANIZATION_ID/customConstraints/custom.targetPoolConstraint
resourceTypes:
- compute.googleapis.com/TargetPool
methodTypes:
- CREATE
- UPDATE
condition: "resource.sessionAffinity == 'CLIENT_IP'"
actionType: ALLOW
displayName: Require target pools to use CLIENT_IP session affinity
description: Target pools must use CLIENT_IP session affinity

Batasan

  • Health check lama (Global lama (HTTP) dan Global lama (HTTPS)) tidak didukung.

  • Untuk beberapa resource Compute Engine, seperti resource kebijakan SSL Compute Engine, batasan kustom juga diterapkan pada metode UPDATE.

Langkah selanjutnya