カスタム制約を使用して Cloud Load Balancing リソースを管理する

Google Cloud 組織のポリシーを使用すると、組織のリソースをプログラマティックに一元管理できます。組織のポリシー管理者は組織のポリシーを定義できます。組織のポリシーは、Google Cloud リソース階層内のGoogle Cloud リソースやそれらのリソースの子孫に適用される、制約と呼ばれる一連の制限です。組織のポリシーは、組織レベル、フォルダレベル、またはプロジェクト レベルで適用できます。

組織のポリシーは、さまざまなGoogle Cloud サービスに事前に定義された制約を提供します。ただし、組織のポリシーで制限されている特定のフィールドをきめ細かく制御する必要がある場合は、カスタム制約を作成して、カスタム組織ポリシーでそれらのカスタム制約を使用することもできます。

次のロード バランシング コンポーネントは、カスタム制約をサポートしています。

利点

  • 費用管理: カスタムの組織のポリシーを使用して、ヘルスチェック プローブの頻度を制限します。
  • セキュリティ、コンプライアンス、ガバナンス: カスタム組織のポリシーを使用して、ポリシーを適用できます。例:

    • 特定のヘルスチェック プロトコルまたはポート範囲の使用を強制する
    • 特定のバックエンド トラフィック プロトコルを禁止する
    • バックエンド バケットで Cloud CDN を有効にすることを必須にするには
    • 転送ルールで特定の Network Service Tiers の使用を必須にするには

Cloud Load Balancing でサポートされているリソース

Cloud Load Balancing では、次のリソースとフィールドにカスタム制約を設定できます。

バックエンド バケット

バックエンド バケット: 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

バックエンド サービス

バックエンド サービス: 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

転送ルール

転送ルール: 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

サービス ロード バランシング ポリシー

サービス ロード バランシング ポリシー: networkservices.googleapis.com/ServiceLbPolicy

  • resource.autoCapacityDrain.enable
  • resource.description
  • resource.failoverConfig.failoverHealthThreshold
  • resource.loadBalancingAlgorithm
  • resource.name

ヘルスチェック

ヘルスチェック: compute.googleapis.com/HealthCheck

  • resource.name
  • resource.description
  • resource.checkIntervalSec
  • resource.timeoutSec
  • resource.unhealthyThreshold
  • resource.healthyThreshold
  • resource.type
  • TCP ヘルスチェック:
    • resource.tcpHealthCheck.port
    • resource.tcpHealthCheck.request
    • resource.tcpHealthCheck.response
    • resource.tcpHealthCheck.proxyHeader
    • resource.tcpHealthCheck.portSpecification
  • SSL ヘルスチェック:
    • resource.sslHealthCheck.port
    • resource.sslHealthCheck.request
    • resource.sslHealthCheck.response
    • resource.sslHealthCheck.proxyHeader
    • resource.sslHealthCheck.portSpecification
  • HTTP ヘルスチェック:
    • resource.httpHealthCheck.port
    • resource.httpHealthCheck.host
    • resource.httpHealthCheck.requestPath
    • resource.httpHealthCheck.proxyHeader
    • resource.httpHealthCheck.response
    • resource.httpHealthCheck.portSpecification
  • HTTPS ヘルスチェック:
    • resource.httpsHealthCheck.port
    • resource.httpsHealthCheck.host
    • resource.httpsHealthCheck.requestPath
    • resource.httpsHealthCheck.proxyHeader
    • resource.httpsHealthCheck.response
    • resource.httpsHealthCheck.portSpecification
  • HTTP/2 ヘルスチェック:
    • resource.http2HealthCheck.port
    • resource.http2HealthCheck.host
    • resource.http2HealthCheck.requestPath
    • resource.http2HealthCheck.proxyHeader
    • resource.http2HealthCheck.response
    • resource.http2HealthCheck.portSpecification
  • gRPC ヘルスチェック:
    • resource.grpcHealthCheck.port
    • resource.grpcHealthCheck.grpcServiceName
    • resource.grpcHealthCheck.portSpecification
  • resource.sourceRegions
  • resource.logConfig
    • resource.logConfig.enable

ターゲット プロキシ

ターゲット TCP プロキシ: compute.googleapis.com/TargetTcpProxy

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

ターゲット SSL プロキシ: compute.googleapis.com/TargetSslProxy

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

ターゲット HTTP プロキシ: compute.googleapis.com/TargetHttpProxy

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

ターゲット HTTPS プロキシ: compute.googleapis.com/TargetHttpsProxy

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

ターゲット gRPC プロキシ: compute.googleapis.com/TargetGrpcProxy

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

URL マップ

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

SSL ポリシー

SSL ポリシー: compute.googleapis.com/SslPolicy

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

ターゲット インスタンス

ターゲット インスタンス: compute.googleapis.com/TargetInstance

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

ターゲット プール

ターゲット プール: compute.googleapis.com/TargetPool

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

サポートされているその他のコンピューティング リソースについては、Compute Engine のカスタム制約のページをご覧ください。

ポリシーの継承

デフォルトでは、組織のポリシーは、そのポリシーを適用したリソースの子孫に継承されます。たとえば、フォルダにポリシーを適用した場合、 Google Cloud はそのフォルダ内のすべてのプロジェクトにそのポリシーを適用します。この動作の詳細と変更方法については、階層評価ルールをご覧ください。

始める前に

  • まだ設定していない場合は、認証を設定します。認証とは、 Google Cloud サービスと API にアクセスするために ID を確認するプロセスです。ローカル開発環境からコードまたはサンプルを実行するには、次のいずれかのオプションを選択して Compute Engine に対する認証を行います。

    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.
  • 組織 ID を把握していることを確認します。

必要なロール

Cloud Load Balancing リソースの組織のポリシーを管理するために必要な権限を取得するには、次の IAM ロールを付与するよう管理者に依頼してください。

ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。

これらの事前定義ロールには、Cloud Load Balancing リソースの組織のポリシーを管理するために必要な権限が含まれています。必要とされる正確な権限については、「必要な権限」セクションを開いてご確認ください。

必要な権限

Cloud Load Balancing リソースの組織のポリシーを管理するには、次の権限が必要です。

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

カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。

カスタム制約を設定する

カスタム制約は、組織のポリシーを適用しているサービスでサポートされるリソース、メソッド、条件、アクションによって定義されます。カスタム制約の条件は、Common Expression Language(CEL)を使用して定義されます。CEL を使用してカスタム制約で条件を作成する方法については、カスタム組織のポリシーの作成と管理の CEL セクションをご覧ください。

カスタム制約を作成し、Google Cloud コンソールまたは gcloud CLI を使用して組織のポリシーで使用するように設定できます。

コンソール

  1. Google Cloud コンソールで、[組織のポリシー] ページに移動します。

    [組織のポリシー] に移動

  2. ページの上部にあるプロジェクト選択ツールを選択します。

  3. [リソースを選択] ウィンドウで、カスタム制約を作成する組織を選択します。

  4. [ カスタム制約] をクリックします。

  5. [表示名] ボックスに制約の名前を入力します。わかりやすい名前を入力してください。このフィールドの最大長は 200 文字です。エラー メッセージで漏えいする可能性があるため、制約名には個人情報(PII)やセンシティブ データを使用しないでください。

  6. [制約 ID] ボックスに、新しいカスタム制約の名前を入力します。カスタム制約は custom. で始まる必要があり、大文字、小文字、数字のみを含めることができます(例: custom.enforceTCPHealthCheckPort1024)。このフィールドの最大長は 70 文字です。接頭辞はカウントされません(例: organizations/123456789/customConstraints/custom.)。

  7. [説明] ボックスに、ポリシー違反が発生したときにエラー メッセージとして表示される制約の説明を入力します。わかりやすい説明を入力してください。このフィールドの最大長は 2,000 文字です。

  8. [リソースの種類] ボックスで、制限するオブジェクトとフィールドを含む Google CloudREST リソースの名前を選択します。例: compute.googleapis.com/HealthCheck

  9. [適用方法] で、REST CREATE メソッドに制約を適用するかどうかを選択します。

  10. 条件を定義するには、[ 条件を編集] をクリックします。

    1. [条件を追加] パネルで、サポートされているサービス リソースを参照する CEL 条件を作成します(例: resource.tcpHealthCheck.port >= 1024)。このフィールドの最大長は 1,000 文字です。

    2. [保存] をクリックします。

  11. [アクション] で、前述の条件を満たしている場合に、評価された方法を許可するか拒否するかを選択します。

  12. [制約を作成] をクリックします。

各フィールドに値を入力すると、このカスタム制約の YAML 構成が右側に表示されます。

gcloud

gcloud CLI を使用してカスタム制約を作成するには、カスタム制約の YAML ファイルを作成します。

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

次のように置き換えます。

  • ORGANIZATION_ID: 組織 ID(123456789 など)。

  • CONSTRAINT_NAME: 新しいカスタム制約に付ける名前。カスタム制約は custom. で始まる必要があり、大文字、小文字、数字のみを含めることができます。例: custom.enforceTCPHealthCheckPort1024。このフィールドの最大長は 70 文字です。接頭辞はカウントされません(例: organizations/123456789/customConstraints/custom.)。

  • RESOURCE_NAME: 制限するオブジェクトとフィールドを含む Compute Engine API REST リソースの名前(URI ではない)。例: HealthCheck

  • CONDITION: サポート対象のサービス リソースの表現に対して書き込まれる CEL 条件。このフィールドの最大長は 1,000 文字です。条件の書き込み先として使用できるリソースの詳細については、サポート対象のリソースをご覧ください。例: "resource.tcpHealthCheck.port >= 1024"

  • ACTION: condition が満たされている場合に実行するアクション。ALLOW または DENY になります。

  • DISPLAY_NAME: 制約の名前。わかりやすい名前を入力してください。このフィールドの最大長は 200 文字です。

  • DESCRIPTION: ポリシー違反時にエラー メッセージとして表示される制約の説明。わかりやすい説明を入力してください。このフィールドの最大長は 2,000 文字です。

カスタム制約の作成方法の詳細については、カスタム組織のポリシーの作成と管理をご覧ください。

新しいカスタム制約の YAML ファイルを作成したら、組織内の組織のポリシーで使用できるように設定する必要があります。カスタム制約を設定するには、gcloud org-policies set-custom-constraint コマンドを使用します。
gcloud org-policies set-custom-constraint CONSTRAINT_PATH
CONSTRAINT_PATH は、カスタム制約ファイルのフルパスに置き換えます。例: /home/user/customconstraint.yaml 完了すると、カスタム制約が組織のポリシーとして Google Cloud 組織のポリシーのリストに表示されます。カスタム制約が存在することを確認するには、gcloud org-policies list-custom-constraints コマンドを使用します。
gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID
ORGANIZATION_ID は、組織リソースの ID に置き換えます。詳細については、組織のポリシーの表示をご覧ください。

カスタム制約を適用する

ブール型制約を適用するには、それを参照する組織のポリシーを作成し、その組織のポリシーを Google Cloud リソースに適用します。

コンソール

  1. Google Cloud コンソールで、[組織のポリシー] ページに移動します。

    [組織のポリシー] に移動

  2. プロジェクト選択ツールで、組織のポリシーを設定するプロジェクトを選択します。
  3. [組織のポリシー] ページのリストで制約を選択して、その制約の [ポリシーの詳細] ページを表示します。
  4. このリソースの組織のポリシーを構成するには、[ポリシーを管理] をクリックします。
  5. [ポリシーの編集] ページで、[Override parent's policy] を選択します。
  6. [ルールを追加] をクリックします。
  7. [適用] セクションで、この組織のポリシーの適用を有効にするかどうかを選択します。
  8. 省略可: タグで組織のポリシーに条件を設定するには、[条件を追加] をクリックします。組織のポリシーに条件付きルールを追加する場合は、少なくとも 1 つは無条件のルールを追加する必要があります。そうしないとポリシーを保存できないのでご注意ください。詳細については、タグ付きの組織のポリシーの設定をご覧ください。
  9. カスタム制約の場合は、[変更内容をテスト] をクリックして、組織のポリシーの効果をシミュレートできます。詳細については、Policy Simulator で組織のポリシーの変更をテストするをご覧ください。
  10. 組織のポリシーを完成させて適用するには、[ポリシーを設定] をクリックします。ポリシーが有効になるまでに最大 15 分かかります。

gcloud

ブール型制約を適用する組織のポリシーを作成するには、制約を参照するポリシー YAML ファイルを作成します。

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

次のように置き換えます。

  • PROJECT_ID: 制約を適用するプロジェクト。
  • CONSTRAINT_NAME: カスタム制約に定義した名前。たとえば、custom.enforceTCPHealthCheckPort1024 のようにします。

制約を含む組織のポリシーを適用するには、次のコマンドを実行します。

    gcloud org-policies set-policy POLICY_PATH
    

POLICY_PATH は、組織のポリシーの YAML ファイルのパスに置き換えます。ポリシーが有効になるまでに最大 15 分かかります。

例: カスタム制約を使用して TLS 機能を制限する

カスタム制約を使用してサポートされているロードバランサの TLS 機能を制限するには、組織で事前定義された constraints/compute.requireSslPolicy 制約を使用するポリシーを定義します。ポリシーを定義したら、次の手順でカスタム制約を設定して使用します。

  1. 事前定義された制約の YAML ファイルを作成します。

    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
    

    次の例では、最小 TLS バージョンを 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. カスタム制約を組織に追加します。

    gcloud org-policies set-custom-constraint PATH_TO_FILE
    
  3. 組織にカスタム制約が存在することを確認します。

    gcloud org-policies list-custom-constraints \
        --organization=ORGANIZATION_ID
    
  4. 制約のポリシー ファイルを作成します。

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

    次のように置き換えます。

    • PROJECT_ID: 実際の Google Cloud プロジェクト ID
    • CONSTRAINT_NAME: 制約名
  5. ポリシーを適用します。

    gcloud org-policies set-policy PATH_TO_POLICY_FILE
    

    PATH_TO_POLICY_FILE は、ポリシー ファイルの完全修飾パスに置き換えます。

  6. 最小 TLS バージョンを 1.2 に制限する YAML ファイルを作成したと仮定します。minTlsVersionTLS_1_0 に設定して SSL ポリシーを作成して、制約をテストします。

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

    出力は次のようになります。

    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.
    

例: TCP ヘルスチェック ポートを 1024 以上に制限する制約を作成する

次の例では、TCP ヘルスチェック ポート番号を 1024 以上に制限するカスタムの制約とポリシーを作成します。

事前に次のものを確認してください。

  • 組織の ID
  • プロジェクト ID

gcloud

  1. 次の情報を含む enforceTCPHealthCheckPort1024.yaml 制約ファイルを作成します。

    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. カスタム制約を設定します。

    gcloud org-policies set-custom-constraint enforceTCPHealthCheckPort1024.yaml
    
  3. 次の情報を含む enforceTCPHealthCheckPort1024-policy.yaml ポリシー ファイルを作成します。この例では、この制約をプロジェクト レベルで適用しますが、組織レベルまたはフォルダレベルで設定することもできます。PROJECT_ID は、実際のプロジェクト ID に置き換えます。

    name: projects/PROJECT_ID/policies/custom.enforceTCPHealthCheckPort1024
    spec:
      rules:
    enforce: true
  4. ポリシーを適用します。

    gcloud org-policies set-policy enforceTCPHealthCheckPort1024-policy.yaml
    
  5. 制約をテストするには、ポート 80 での TCP ヘルスチェックを作成してみます。この処理は許可されません。

    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 \
    
    

    出力は次のようになります。

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

一般的なユースケースのその他の例

以下の各セクションでは、役立つ可能性のあるカスタム制約の構文について説明します。

バックエンド バケット

ユースケース 構文
すべてのバックエンド バケットで 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.

バックエンド サービス

ユースケース 構文
バックエンド サービス プロトコルとして HTTP と TCP の使用を禁止する
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.

転送ルール

ユースケース 構文
転送ルールでスタンダード ティアを使用することを必須にする
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.

ヘルスチェック

ユースケース 構文
すべてのヘルスチェック プロトコルが 1024 番以上のポートで実行されるようにします。
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.
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.
高頻度のヘルスチェック プローブを防ぐ
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.

ターゲット プロキシ

ユースケース 構文
クライアント HTTPS キープアライブ タイムアウト値が 1,000 秒を超える場合は許可しない
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.

URL マップ

ユースケース 構文
URL マップに 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.

ターゲット インスタンス

ユースケース 構文
ターゲット インスタンスの名前が「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"

ターゲット プール

ユースケース 構文
ターゲット プールに 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

制限事項

次のステップ