Google Cloud 组织政策可让您以编程方式集中控制组织的资源。作为组织政策管理员,您可以定义组织政策,这是一组称为限制条件的限制,会应用于Google Cloud 资源层次结构中的Google Cloud 资源及其后代。您可以在组织、文件夹或项目级强制执行组织政策。
组织政策为各种Google Cloud 服务提供预定义限制条件。但是,如果您想要更精细地控制和自定义组织政策中受限的特定字段,还可以创建自定义限制条件并在自定义组织政策中使用这些自定义限制条件。
以下负载均衡组件支持自定义限制条件:
实例群组等 Compute Engine 资源和 VPC 网络和子网等 VPC 资源也支持自定义限制条件。
优势
- 费用管理:使用自定义组织政策限制健康检查探测频率。
安全、合规性和治理:您可以使用自定义组织政策强制执行政策。例如:
- 强制使用特定的健康检查协议或端口范围
- 禁止使用特定的后端流量协议
- 要求后端存储桶启用 Cloud CDN
- 要求转发规则使用特定的 Network Service Tiers
Cloud Load Balancing 支持的资源
对于 Cloud Load Balancing,您可以对以下资源和字段设置自定义限制条件。
后端存储桶
后端存储桶:compute.googleapis.com/BackendBucket
resource.nameresource.descriptionresource.bucketNameresource.enableCdnresource.cdnPolicyresource.cdnPolicy.bypassCacheOnRequestHeadersresource.cdnPolicy.bypassCacheOnRequestHeaders.headerName
resource.cdnPolicy.cacheKeyPolicyresource.cdnPolicy.cacheKeyPolicy.includeHttpHeadersresource.cdnPolicy.cacheKeyPolicy.queryStringWhitelistresource.cdnPolicy.signedUrlCacheMaxAgeSec
resource.compressionModeresource.customResponseHeaders
后端服务
后端服务:compute.googleapis.com/BackendService
resource.nameresource.descriptionresource.portresource.portNameresource.protocolresource.backendsresource.backends.balancingModeresource.backends.capacityScalerresource.backends.descriptionresource.backends.failoverresource.backends.maxConnectionsresource.backends.maxConnectionsPerEndpointresource.backends.maxConnectionsPerInstanceresource.backends.maxRateresource.backends.maxRatePerEndpointresource.backends.maxRatePerInstanceresource.backends.maxUtilizationresource.backends.preference
resource.enableCDNresource.cdnPolicyresource.cdnPolicy.bypassCacheOnRequestHeadersresource.cdnPolicy.bypassCacheOnRequestHeaders.headerName
resource.cdnPolicy.cacheKeyPolicyresource.cdnPolicy.cacheKeyPolicy.includeHostresource.cdnPolicy.cacheKeyPolicy.includeHttpHeadersresource.cdnPolicy.cacheKeyPolicy.includeNamedCookiesresource.cdnPolicy.cacheKeyPolicy.includeProtocolresource.cdnPolicy.cacheKeyPolicy.includeQueryStringresource.cdnPolicy.cacheKeyPolicy.queryStringBlacklistresource.cdnPolicy.cacheKeyPolicy.queryStringWhitelist
resource.cdnPolicy.cacheModeresource.cdnPolicy.clientTtlresource.cdnPolicy.defaultTtlresource.cdnPolicy.maxTtlresource.cdnPolicy.negativeCachingresource.cdnPolicy.negativeCachingPolicyresource.cdnPolicy.negativeCachingPolicy.coderesource.cdnPolicy.negativeCachingPolicy.ttl
resource.cdnPolicy.requestCoalescingresource.cdnPolicy.serveWhileStaleresource.cdnPolicy.signedUrlCacheMaxAgeSec
resource.circuitBreakersresource.circuitBreakers.maxConnectionsresource.circuitBreakers.maxPendingRequestsresource.circuitBreakers.maxRequestsresource.circuitBreakers.maxRequestsPerConnectionresource.circuitBreakers.maxRetries
resource.compressionModeresource.connectionDrainingresource.connectionDraining.drainingTimeoutSec
resource.connectionTrackingPolicyresource.connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackendsresource.connectionTrackingPolicy.enableStrongAffinityresource.connectionTrackingPolicy.idleTimeoutSecresource.connectionTrackingPolicy.trackingMode
resource.consistentHashresource.consistentHash.httpCookieresource.consistentHash.httpCookie.nameresource.consistentHash.httpCookie.pathresource.consistentHash.httpCookie.ttlresource.consistentHash.httpCookie.ttl.nanosresource.consistentHash.httpCookie.ttl.seconds
resource.consistentHash.minimumRingSize
resource.customRequestHeadersresource.customResponseHeadersresource.affinityCookieTtlSecresource.failoverPolicyresource.failoverPolicy.disableConnectionDrainOnFailoverresource.failoverPolicy.dropTrafficIfUnhealthyresource.failoverPolicy.failoverRatio
resource.iapresource.iap.enabledresource.iap.oauth2ClientId
resource.ipAddressSelectionPolicyresource.loadBalancingSchemeresource.localityLbPoliciesresource.localityLbPolicies.customPolicyresource.localityLbPolicies.customPolicy.dataresource.localityLbPolicies.customPolicy.nameresource.localityLbPolicies.policyresource.localityLbPolicies.policy.name
resource.logConfigresource.logConfig.enableresource.logConfig.optionalFieldsresource.logConfig.optionalModeresource.logConfig.sampleRate
resource.maxStreamDurationresource.maxStreamDuration.nanosresource.maxStreamDuration.seconds
resource.outlierDetectionresource.outlierDetection.baseEjectionTimeresource.outlierDetection.baseEjectionTime.nanosresource.outlierDetection.baseEjectionTime.secondsresource.outlierDetection.consecutiveGatewayFailureresource.outlierDetection.enforcingConsecutiveErrorsresource.outlierDetection.enforcingConsecutiveGatewayFailureresource.outlierDetection.enforcingSuccessRateresource.outlierDetection.maxEjectionPercentresource.outlierDetection.successRateMinimumHostsresource.outlierDetection.successRateRequestVolumeresource.outlierDetection.successRateStdevFactor
resource.securitySettingsresource.securitySettings.awsV4Authenticationresource.securitySettings.awsV4Authentication.accessKeyIdresource.securitySettings.awsV4Authentication.accessKeyVersionresource.securitySettings.subjectAltNames
resource.sessionAffinityresource.subsettingresource.subsetting.policy
resource.timeoutSecresource.strongSessionAffinityCookieresource.strongSessionAffinityCookie.nameresource.strongSessionAffinityCookie.pathresource.strongSessionAffinityCookie.ttlresource.strongSessionAffinityCookie.ttl.nanosresource.strongSessionAffinityCookie.ttl.seconds
转发规则
转发规则:compute.googleapis.com/ForwardingRule
resource.nameresource.descriptionresource.allowGlobalAccessresource.allowPscGlobalAccessresource.allPortsresource.IPProtocolresource.ipVersionresource.isMirroringCollectorresource.loadBalancingSchemeresource.metadataFiltersresource.metadataFilters.filterLabelsresource.metadataFilters.filterLabels.nameresource.metadataFilters.filterLabels.valueresource.metadataFilters.filterMatchCriteria
resource.networkTierresource.noAutomateDnsZoneresource.portRangeresource.portsresource.serviceDirectoryRegistrationsresource.serviceDirectoryRegistrations.namespaceresource.serviceDirectoryRegistrations.serviceresource.serviceDirectoryRegistrations.serviceDirectoryRegion
resource.serviceLabelresource.sourceIpRanges
健康检查
健康检查:compute.googleapis.com/HealthCheck
resource.nameresource.descriptionresource.checkIntervalSecresource.timeoutSecresource.unhealthyThresholdresource.healthyThresholdresource.type- TCP 健康检查:
resource.tcpHealthCheck.portresource.tcpHealthCheck.requestresource.tcpHealthCheck.responseresource.tcpHealthCheck.proxyHeaderresource.tcpHealthCheck.portSpecification
- SSL 健康检查:
resource.sslHealthCheck.portresource.sslHealthCheck.requestresource.sslHealthCheck.responseresource.sslHealthCheck.proxyHeaderresource.sslHealthCheck.portSpecification
- HTTP 健康检查:
resource.httpHealthCheck.portresource.httpHealthCheck.hostresource.httpHealthCheck.requestPathresource.httpHealthCheck.proxyHeaderresource.httpHealthCheck.responseresource.httpHealthCheck.portSpecification
- HTTPS 健康检查:
resource.httpsHealthCheck.portresource.httpsHealthCheck.hostresource.httpsHealthCheck.requestPathresource.httpsHealthCheck.proxyHeaderresource.httpsHealthCheck.responseresource.httpsHealthCheck.portSpecification
- HTTP/2 健康检查:
resource.http2HealthCheck.portresource.http2HealthCheck.hostresource.http2HealthCheck.requestPathresource.http2HealthCheck.proxyHeaderresource.http2HealthCheck.responseresource.http2HealthCheck.portSpecification
- gRPC 健康检查:
resource.grpcHealthCheck.portresource.grpcHealthCheck.grpcServiceNameresource.grpcHealthCheck.portSpecification
resource.sourceRegionsresource.logConfigresource.logConfig.enable
网络端点组
网络端点群组:compute.googleapis.com/NetworkEndpointGroup
resource.annotationsresource.appEngine.serviceresource.appEngine.urlMaskresource.appEngine.versionresource.cloudFunction.functionresource.cloudFunction.urlMaskresource.cloudRun.serviceresource.cloudRun.tagresource.cloudRun.urlMaskresource.defaultPortresource.descriptionresource.nameresource.networkresource.networkEndpointTyperesource.pscData.producerPortresource.pscTargetServiceresource.subnetwork
服务负载均衡政策
服务负载均衡政策:networkservices.googleapis.com/ServiceLbPolicy
resource.autoCapacityDrain.enableresource.descriptionresource.failoverConfig.failoverHealthThresholdresource.loadBalancingAlgorithmresource.name
SSL 政策
SSL 政策:compute.googleapis.com/SslPolicy
resource.profileresource.nameresource.descriptionresource.minTlsVersionresource.customFeatures
目标实例
目标实例:compute.googleapis.com/TargetInstance
resource.nameresource.descriptionresource.natPolicy
目标池数
目标池:compute.googleapis.com/TargetPool
resource.nameresource.descriptionresource.sessionAffinityresource.failoverRatio
目标代理
目标 TCP 代理:compute.googleapis.com/TargetTcpProxy
resource.nameresource.descriptionresource.proxyBindresource.proxyHeader
目标 SSL 代理:compute.googleapis.com/TargetSslProxy
resource.nameresource.descriptionresource.proxyHeader
目标 HTTP 代理:compute.googleapis.com/TargetHttpProxy
resource.nameresource.descriptionresource.proxyBindresource.httpKeepAliveTimeoutSec
目标 HTTPS 代理:compute.googleapis.com/TargetHttpsProxy
resource.nameresource.descriptionresource.proxyBindresource.httpKeepAliveTimeoutSecresource.quicOverrideresource.tlsEarlyData
目标 gRPC 代理:compute.googleapis.com/TargetGrpcProxy
resource.nameresource.descriptionresource.validateForProxyless
网址映射
网址映射:compute.googleapis.com/UrlMap
resource.nameresource.descriptionresource.defaultCustomErrorResponsePolicyresource.defaultCustomErrorResponsePolicy.errorResponseRulesresource.defaultCustomErrorResponsePolicy.errorResponseRules.matchResponseCodesresource.defaultCustomErrorResponsePolicy.errorResponseRules.overrideResponseCoderesource.defaultCustomErrorResponsePolicy.errorResponseRules.path
resource.defaultRouteActionresource.defaultRouteAction.corsPolicyresource.defaultRouteAction.corsPolicy.allowCredentialsresource.defaultRouteAction.corsPolicy.allowHeadersresource.defaultRouteAction.corsPolicy.allowMethodsresource.defaultRouteAction.corsPolicy.allowOriginsresource.defaultRouteAction.corsPolicy.allowOriginRegexesresource.defaultRouteAction.corsPolicy.disabledresource.defaultRouteAction.corsPolicy.exposeHeadersresource.defaultRouteAction.corsPolicy.maxAgeresource.defaultRouteAction.faultInjectionPolicyresource.defaultRouteAction.faultInjectionPolicy.abortresource.defaultRouteAction.faultInjectionPolicy.abort.httpStatusresource.defaultRouteAction.faultInjectionPolicy.abort.percentage
resource.defaultRouteAction.faultInjectionPolicy.delayresource.defaultRouteAction.faultInjectionPolicy.delay.percentageresource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelayresource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanosresource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds
resource.defaultRouteAction.maxStreamDurationresource.defaultRouteAction.maxStreamDuration.nanosresource.defaultRouteAction.maxStreamDuration.secondsresource.defaultRouteAction.requestMirrorPolicyresource.defaultRouteAction.retryPolicyresource.defaultRouteAction.retryPolicy.numRetriesresource.defaultRouteAction.retryPolicy.perTryTimeoutresource.defaultRouteAction.retryPolicy.perTryTimeout.nanosresource.defaultRouteAction.retryPolicy.perTryTimeout.seconds
resource.defaultRouteAction.retryPolicy.retryConditionsresource.defaultRouteAction.timeoutresource.defaultRouteAction.timeout.nanosresource.defaultRouteAction.timeout.secondsresource.defaultRouteAction.urlRewriteresource.defaultRouteAction.urlRewrite.hostRewriteresource.defaultRouteAction.urlRewrite.pathPrefixRewriteresource.defaultRouteAction.urlRewrite.pathTemplateRewriteresource.defaultRouteAction.weightedBackendServicesresource.defaultRouteAction.weightedBackendServices.headerActionresource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAddresource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerNameresource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValueresource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.replaceresource.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToRemoveresource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAddresource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerNameresource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValueresource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.replaceresource.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToRemove
resource.defaultRouteAction.weightedBackendServices.weight
resource.defaultUrlRedirectresource.defaultUrlRedirect.hostRedirectresource.defaultUrlRedirect.httpsRedirectresource.defaultUrlRedirect.pathRedirectresource.defaultUrlRedirect.prefixRedirectresource.defaultUrlRedirect.redirectResponseCoderesource.defaultUrlRedirect.stripQuery
resource.headerActionresource.headerAction.requestHeadersToAddresource.headerAction.requestHeadersToAdd.headerNameresource.headerAction.requestHeadersToAdd.headerValueresource.headerAction.requestHeadersToAdd.replaceresource.headerAction.requestHeadersToRemoveresource.headerAction.responseHeadersToAddresource.headerAction.responseHeadersToAdd.headerNameresource.headerAction.responseHeadersToAdd.headerValueresource.headerAction.responseHeadersToAdd.replaceresource.headerAction.responseHeadersToRemove
resource.hostRulesresource.hostRules.descriptionresource.hostRules.hostsresource.hostRules.pathMatcher
resource.pathMatchersresource.pathMatchers.nameresource.pathMatchers.descriptionresource.pathMatchers.defaultCustomErrorResponsePolicyresource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRulesresource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules.matchResponseCodesresource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules.overrideResponseCoderesource.pathMatchers.defaultCustomErrorResponsePolicy.errorResponseRules.path
resource.pathMatchers.defaultRouteActionresource.pathMatchers.defaultRouteAction.corsPolicyresource.pathMatchers.defaultRouteAction.corsPolicy.allowCredentialsresource.pathMatchers.defaultRouteAction.corsPolicy.allowHeadersresource.pathMatchers.defaultRouteAction.corsPolicy.allowMethodsresource.pathMatchers.defaultRouteAction.corsPolicy.allowOriginsresource.pathMatchers.defaultRouteAction.corsPolicy.allowOriginRegexesresource.pathMatchers.defaultRouteAction.corsPolicy.disabledresource.pathMatchers.defaultRouteAction.corsPolicy.exposeHeadersresource.pathMatchers.defaultRouteAction.corsPolicy.maxAge
resource.pathMatchers.defaultRouteAction.faultInjectionPolicyresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.abortresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.abort.httpStatusresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.abort.percentageresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delayresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.percentageresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.fixedDelayresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanosresource.pathMatchers.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds
resource.pathMatchers.defaultRouteAction.maxStreamDurationresource.pathMatchers.defaultRouteAction.maxStreamDuration.nanosresource.pathMatchers.defaultRouteAction.maxStreamDuration.seconds
resource.pathMatchers.defaultRouteAction.requestMirrorPolicyresource.pathMatchers.defaultRouteAction.retryPolicyresource.pathMatchers.defaultRouteAction.retryPolicy.numRetriesresource.pathMatchers.defaultRouteAction.retryPolicy.perTryTimeoutresource.pathMatchers.defaultRouteAction.retryPolicy.perTryTimeout.nanosresource.pathMatchers.defaultRouteAction.retryPolicy.perTryTimeout.secondsresource.pathMatchers.defaultRouteAction.retryPolicy.retryConditions
resource.pathMatchers.defaultRouteAction.timeoutresource.pathMatchers.defaultRouteAction.timeout.nanosresource.pathMatchers.defaultRouteAction.timeout.seconds
resource.pathMatchers.defaultRouteAction.urlRewriteresource.pathMatchers.defaultRouteAction.urlRewrite.hostRewriteresource.pathMatchers.defaultRouteAction.urlRewrite.pathPrefixRewriteresource.pathMatchers.defaultRouteAction.urlRewrite.pathTemplateRewrite
resource.pathMatchers.defaultRouteAction.weightedBackendServicesresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerActionresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAddresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerNameresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValueresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToAdd.replace
resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.requestHeadersToRemoveresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAddresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerNameresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValueresource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToAdd.replace
resource.pathMatchers.defaultRouteAction.weightedBackendServices.headerAction.responseHeadersToRemoveresource.pathMatchers.defaultRouteAction.weightedBackendServices.weight
resource.pathMatchers.defaultUrlRedirectresource.pathMatchers.defaultUrlRedirect.hostRedirectresource.pathMatchers.defaultUrlRedirect.httpsRedirectresource.pathMatchers.defaultUrlRedirect.pathRedirectresource.pathMatchers.defaultUrlRedirect.prefixRedirectresource.pathMatchers.defaultUrlRedirect.redirectResponseCoderesource.pathMatchers.defaultUrlRedirect.stripQueryresource.pathMatchers.headerActionresource.pathMatchers.headerAction.requestHeadersToAddresource.pathMatchers.headerAction.requestHeadersToAdd.headerNameresource.pathMatchers.headerAction.requestHeadersToAdd.headerValueresource.pathMatchers.headerAction.requestHeadersToAdd.replaceresource.pathMatchers.headerAction.requestHeadersToRemoveresource.pathMatchers.headerAction.responseHeadersToAddresource.pathMatchers.headerAction.responseHeadersToAdd.headerNameresource.pathMatchers.headerAction.responseHeadersToAdd.headerValueresource.pathMatchers.headerAction.responseHeadersToAdd.replaceresource.pathMatchers.headerAction.responseHeadersToRemoveresource.pathMatchers.pathRulesresource.pathMatchers.pathRules.pathsresource.pathMatchers.pathRules.customErrorResponsePolicyresource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRulesresource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules.matchResponseCodesresource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules.overrideResponseCoderesource.pathMatchers.pathRules.customErrorResponsePolicy.errorResponseRules.path
resource.pathMatchers.pathRules.routeActionresource.pathMatchers.pathRules.routeAction.corsPolicyresource.pathMatchers.pathRules.routeAction.corsPolicy.allowCredentialsresource.pathMatchers.pathRules.routeAction.corsPolicy.allowHeadersresource.pathMatchers.pathRules.routeAction.corsPolicy.allowMethodsresource.pathMatchers.pathRules.routeAction.corsPolicy.allowOriginsresource.pathMatchers.pathRules.routeAction.corsPolicy.allowOriginRegexesresource.pathMatchers.pathRules.routeAction.corsPolicy.disabledresource.pathMatchers.pathRules.routeAction.corsPolicy.exposeHeadersresource.pathMatchers.pathRules.routeAction.corsPolicy.maxAgeresource.pathMatchers.pathRules.routeAction.faultInjectionPolicyresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.abortresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.abort.httpStatusresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.abort.percentage
resource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delayresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.percentageresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.fixedDelayresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.fixedDelay.nanosresource.pathMatchers.pathRules.routeAction.faultInjectionPolicy.delay.fixedDelay.seconds
resource.pathMatchers.pathRules.routeAction.maxStreamDurationresource.pathMatchers.pathRules.routeAction.maxStreamDuration.nanosresource.pathMatchers.pathRules.routeAction.maxStreamDuration.secondsresource.pathMatchers.pathRules.routeAction.requestMirrorPolicyresource.pathMatchers.pathRules.routeAction.retryPolicyresource.pathMatchers.pathRules.routeAction.retryPolicy.numRetriesresource.pathMatchers.pathRules.routeAction.retryPolicy.perTryTimeoutresource.pathMatchers.pathRules.routeAction.retryPolicy.perTryTimeout.nanosresource.pathMatchers.pathRules.routeAction.retryPolicy.perTryTimeout.seconds
resource.pathMatchers.pathRules.routeAction.retryPolicy.retryConditionsresource.pathMatchers.pathRules.routeAction.timeoutresource.pathMatchers.pathRules.routeAction.timeout.nanosresource.pathMatchers.pathRules.routeAction.timeout.secondsresource.pathMatchers.pathRules.routeAction.urlRewriteresource.pathMatchers.pathRules.routeAction.urlRewrite.hostRewriteresource.pathMatchers.pathRules.routeAction.urlRewrite.pathPrefixRewriteresource.pathMatchers.pathRules.routeAction.urlRewrite.pathTemplateRewriteresource.pathMatchers.pathRules.routeAction.weightedBackendServicesresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerActionresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAddresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerNameresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValueresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.replaceresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.requestHeadersToRemoveresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAddresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerNameresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValueresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.replaceresource.pathMatchers.pathRules.routeAction.weightedBackendServices.headerAction.responseHeadersToRemove
resource.pathMatchers.pathRules.routeAction.weightedBackendServices.weight
resource.pathMatchers.pathRules.urlRedirectresource.pathMatchers.pathRules.urlRedirect.hostRedirectresource.pathMatchers.pathRules.urlRedirect.httpsRedirectresource.pathMatchers.pathRules.urlRedirect.pathRedirectresource.pathMatchers.pathRules.urlRedirect.prefixRedirectresource.pathMatchers.pathRules.urlRedirect.redirectResponseCoderesource.pathMatchers.pathRules.urlRedirect.stripQuery
resource.pathMatchers.routeRulesresource.pathMatchers.routeRules.descriptionresource.pathMatchers.routeRules.priorityresource.pathMatchers.routeRules.customErrorResponsePolicyresource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRulesresource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules.matchResponseCodesresource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules.overrideResponseCoderesource.pathMatchers.routeRules.customErrorResponsePolicy.errorResponseRules.path
resource.pathMatchers.routeRules.headerActionresource.pathMatchers.routeRules.headerAction.requestHeadersToAddresource.pathMatchers.routeRules.headerAction.requestHeadersToAdd.headerNameresource.pathMatchers.routeRules.headerAction.requestHeadersToAdd.headerValueresource.pathMatchers.routeRules.headerAction.requestHeadersToAdd.replaceresource.pathMatchers.routeRules.headerAction.requestHeadersToRemoveresource.pathMatchers.routeRules.headerAction.responseHeadersToAddresource.pathMatchers.routeRules.headerAction.responseHeadersToAdd.headerNameresource.pathMatchers.routeRules.headerAction.responseHeadersToAdd.headerValueresource.pathMatchers.routeRules.headerAction.responseHeadersToAdd.replaceresource.pathMatchers.routeRules.headerAction.responseHeadersToRemove
resource.pathMatchers.routeRules.matchRulesresource.pathMatchers.routeRules.matchRules.fullPathMatchresource.pathMatchers.routeRules.matchRules.headerMatchesresource.pathMatchers.routeRules.matchRules.headerMatches.exactMatchresource.pathMatchers.routeRules.matchRules.headerMatches.headerNameresource.pathMatchers.routeRules.matchRules.headerMatches.invertMatchresource.pathMatchers.routeRules.matchRules.headerMatches.prefixMatchresource.pathMatchers.routeRules.matchRules.headerMatches.presentMatchresource.pathMatchers.routeRules.matchRules.headerMatches.rangeMatchresource.pathMatchers.routeRules.matchRules.headerMatches.rangeMatch.rangeStartresource.pathMatchers.routeRules.matchRules.headerMatches.rangeMatch.rangeEnd
resource.pathMatchers.routeRules.matchRules.headerMatches.regexMatchresource.pathMatchers.routeRules.matchRules.headerMatches.suffixMatchresource.pathMatchers.routeRules.matchRules.ignoreCaseresource.pathMatchers.routeRules.matchRules.metadataFiltersresource.pathMatchers.routeRules.matchRules.metadataFilters.filterLabelsresource.pathMatchers.routeRules.matchRules.metadataFilters.filterLabels.nameresource.pathMatchers.routeRules.matchRules.metadataFilters.filterLabels.value
resource.pathMatchers.routeRules.matchRules.metadataFilters.filterMatchCriteriaresource.pathMatchers.routeRules.matchRules.pathTemplateMatchresource.pathMatchers.routeRules.matchRules.prefixMatchresource.pathMatchers.routeRules.matchRules.queryParameterMatchesresource.pathMatchers.routeRules.matchRules.queryParameterMatches.nameresource.pathMatchers.routeRules.matchRules.queryParameterMatches.exactMatchresource.pathMatchers.routeRules.matchRules.queryParameterMatches.presentMatchresource.pathMatchers.routeRules.matchRules.queryParameterMatches.regexMatchresource.pathMatchers.routeRules.matchRules.regexMatch
resource.pathMatchers.routeRules.routeActionresource.pathMatchers.routeRules.routeAction.corsPolicyresource.pathMatchers.routeRules.routeAction.corsPolicy.allowCredentialsresource.pathMatchers.routeRules.routeAction.corsPolicy.allowHeadersresource.pathMatchers.routeRules.routeAction.corsPolicy.allowMethodsresource.pathMatchers.routeRules.routeAction.corsPolicy.allowOriginsresource.pathMatchers.routeRules.routeAction.corsPolicy.allowOriginRegexesresource.pathMatchers.routeRules.routeAction.corsPolicy.disabledresource.pathMatchers.routeRules.routeAction.corsPolicy.exposeHeadersresource.pathMatchers.routeRules.routeAction.corsPolicy.maxAgeresource.pathMatchers.routeRules.routeAction.faultInjectionPolicyresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.abortresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.abort.httpStatusresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.abort.percentage
resource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delayresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.percentageresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.fixedDelayresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.fixedDelay.nanosresource.pathMatchers.routeRules.routeAction.faultInjectionPolicy.delay.fixedDelay.seconds
resource.pathMatchers.routeRules.routeAction.maxStreamDurationresource.pathMatchers.routeRules.routeAction.maxStreamDuration.nanosresource.pathMatchers.routeRules.routeAction.maxStreamDuration.secondsresource.pathMatchers.routeRules.routeAction.requestMirrorPolicyresource.pathMatchers.routeRules.routeAction.retryPolicyresource.pathMatchers.routeRules.routeAction.retryPolicy.numRetriesresource.pathMatchers.routeRules.routeAction.retryPolicy.perTryTimeoutresource.pathMatchers.routeRules.routeAction.retryPolicy.perTryTimeout.nanosresource.pathMatchers.routeRules.routeAction.retryPolicy.perTryTimeout.seconds
resource.pathMatchers.routeRules.routeAction.retryPolicy.retryConditionsresource.pathMatchers.routeRules.routeAction.timeoutresource.pathMatchers.routeRules.routeAction.timeout.nanosresource.pathMatchers.routeRules.routeAction.timeout.secondsresource.pathMatchers.routeRules.routeAction.urlRewriteresource.pathMatchers.routeRules.routeAction.urlRewrite.hostRewriteresource.pathMatchers.routeRules.routeAction.urlRewrite.pathPrefixRewriteresource.pathMatchers.routeRules.routeAction.urlRewrite.pathTemplateRewriteresource.pathMatchers.routeRules.routeAction.weightedBackendServicesresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerActionresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAddresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerNameresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.headerValueresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToAdd.replaceresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.requestHeadersToRemoveresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAddresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerNameresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.headerValueresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToAdd.replaceresource.pathMatchers.routeRules.routeAction.weightedBackendServices.headerAction.responseHeadersToRemove
resource.pathMatchers.routeRules.routeAction.weightedBackendServices.weight
resource.pathMatchers.routeRules.urlRedirectresource.pathMatchers.routeRules.urlRedirect.hostRedirectresource.pathMatchers.routeRules.urlRedirect.httpsRedirectresource.pathMatchers.routeRules.urlRedirect.pathRedirectresource.pathMatchers.routeRules.urlRedirect.prefixRedirectresource.pathMatchers.routeRules.urlRedirect.redirectResponseCoderesource.pathMatchers.routeRules.urlRedirect.stripQuery
resource.testsresource.tests.descriptionresource.tests.expectedOutputUrlresource.tests.expectedRedirectResponseCoderesource.tests.headersresource.tests.headers.nameresource.tests.headers.valueresource.tests.hostresource.tests.path
对于其他受支持的计算资源,请参阅 Compute Engine 自定义限制条件页面了解详情。
政策继承
如果您对资源强制执行政策,默认情况下,该资源的后代会继承组织政策。例如,如果您对某个文件夹强制执行一项政策, Google Cloud 会对该文件夹中的所有项目强制执行该政策。如需详细了解此行为及其更改方式,请参阅层次结构评估规则。
准备工作
-
如果您尚未设置身份验证,请进行设置。身份验证用于验证您的身份,以便访问 Google Cloud 服务和 API。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 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
-
安装 Google Cloud CLI。 安装完成后,运行以下命令来初始化 Google Cloud CLI:
gcloud init如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
- Set a default region and zone.
- 请确保您知道您的组织 ID。
所需的角色
如需获得管理 Cloud Load Balancing 资源的组织政策所需的权限,请让您的管理员为您授予以下 IAM 角色:
-
组织 resource_types 的 Organization Policy Administrator (
roles/orgpolicy.policyAdmin) -
测试负载均衡资源的限制条件:项目资源的 Compute Load Balancer Admin (v1) (
roles/compute.loadBalancerAdmin.v1)
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
这些预定义角色包含管理 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
设置自定义限制条件
自定义限制条件由实施组织政策的服务支持的资源、方法、条件和操作定义。自定义限制条件的条件使用通用表达式语言 (CEL) 进行定义。如需详细了解如何使用 CEL 构建自定义限制条件中的条件,请参阅创建和管理自定义组织政策的 CEL 部分。
您可以使用 Google Cloud 控制台或 gcloud CLI 创建自定义限制条件并将其设置为在组织政策中使用。
控制台
在 Google Cloud 控制台中,转到组织政策页面。
选择页面顶部的项目选择器。
在选择资源窗口中,选择要为其创建自定义限制条件的组织。
点击 自定义限制条件。
在显示名称框中,为限制条件输入一个易记的名称。此字段的最大长度为 200 个字符。 请勿在限制条件名称中使用 PII 或敏感数据,因为这些可能会在错误消息中公开。
在限制条件 ID 框中,为新的自定义限制条件输入所需的名称。自定义限制条件必须以
custom.开头,只能包含大写字母、小写字母或数字,例如custom.enforceTCPHealthCheckPort1024。该字段的长度上限为 70 个字符,不计算前缀(例如organizations/123456789/customConstraints/custom.)。在说明框中,输入直观易懂的限制条件说明,在违反政策时此说明内容会以错误消息的形式显示。此字段的最大长度为 2000 个字符。
在资源类型框中,选择包含要限制的对象和字段的 Google CloudREST 资源的名称。例如
compute.googleapis.com/HealthCheck。在强制执行方法下,选择是否对 REST
CREATE方法强制执行限制条件。如需定义条件,请点击 修改条件。
在添加条件面板中,创建一个引用受支持的服务资源的 CEL 条件,例如
。此字段的最大长度为 1,000 个字符。resource.tcpHealthCheck.port >= 1024点击保存。
在操作下,选择在满足上述条件时是允许还是拒绝评估的方法。
点击创建限制条件。
在每个字段中输入值后,右侧将显示此自定义限制条件的等效 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:直观易懂的限制条件说明,在违反政策时显示为错误消息。 此字段的最大长度为 2000 个字符。
如需详细了解如何创建自定义限制条件,请参阅创建和管理自定义组织政策。
为新的自定义限制条件创建 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 资源。控制台
- 在 Google Cloud 控制台中,前往组织政策页面。
- 在项目选择器中,选择要设置组织政策的项目。
- 从组织政策页面上的列表中选择您的限制条件,以查看该限制条件的政策详情页面。
- 如需为该资源配置组织政策,请点击管理政策。
- 在修改政策页面,选择覆盖父级政策。
- 点击添加规则。
- 在强制执行部分中,选择开启还是关闭此组织政策的强制执行。
- (可选)如需使组织政策成为基于某个标记的条件性政策,请点击添加条件。请注意,如果您向组织政策添加条件规则,则必须至少添加一个无条件规则,否则无法保存政策。如需了解详情,请参阅设置带有标记的组织政策。
- 点击测试更改以模拟组织政策的效果。政策模拟不适用于旧版托管式限制。如需了解详情,请参阅使用 Policy Simulator 测试组织政策更改。
- 若要完成并应用组织政策,请点击设置政策。该政策最长需要 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限制条件的政策。定义政策后,请按照以下步骤设置自定义限制条件并使用它们。为自定义限制条件创建 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.以下是另一个自定义限制条件的示例,该限制条件仅允许在满足以下条件时创建 SSL 资源:
- 最低 TLS 版本设置为 1.2。
- SSL 政策具有 CUSTOM 配置文件,可让您单独选择 SSL 功能。
- SSL 政策不包含 ChaCha20-Poly1305 加密套件。
name: organizations/ORGANIZATION_ID/customConstraints/custom.restrictLbTlsCapabilities resourceTypes: - compute.googleapis.com/SslPolicy methodTypes: - CREATE - UPDATE condition: resource.minTlsVersion == "TLS_1_2" && resource.profile == "CUSTOM" && !resource.customFeatures.exists(feature, feature.contains("CHACHA20_POLY1305")) actionType: ALLOW displayName: Restrict Load Balancing TLS Capabilities description: Only allow SSL Policy resources to be created or updated if the minimum TLS version is 1.2, profile is CUSTOM, and no ChaCha20-Poly1305 cipher suite is used where this custom constraint is enforced.将自定义限制条件添加到您的组织。
gcloud org-policies set-custom-constraint PATH_TO_FILE
验证您的组织中是否存在自定义限制条件。
gcloud org-policies list-custom-constraints \ --organization=ORGANIZATION_ID为限制条件创建政策文件。
name: projects/PROJECT_ID/policies/custom.CONSTRAINT_NAME spec: rules: – enforce: true
替换以下内容:
PROJECT_ID:您的 Google Cloud 项目 IDCONSTRAINT_NAME:限制条件名称
强制执行该政策:
gcloud org-policies set-policy PATH_TO_POLICY_FILE
将
PATH_TO_POLICY_FILE替换为政策文件的完全限定路径。假设您已创建了 YAML 文件以将最低 TLS 版本限制为 1.2,请通过创建将
minTlsVersion设置为TLS_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 健康检查端口限制为至少 1,024
以下示例创建一个自定义限制条件和政策,以将 TCP 健康检查端口号限制为至少
1024。在开始之前,您需要了解以下内容:
- 您的组织 ID
项目 ID
gcloud
使用以下信息创建
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.
设置自定义限制条件。
gcloud org-policies set-custom-constraint enforceTCPHealthCheckPort1024.yaml
创建一份
enforceTCPHealthCheckPort1024-policy.yaml具有以下信息政策文件。在此示例中,我们在项目级层强制执行此限制条件,但您也可以在组织或文件夹级层设置此限制条件。 请将PROJECT_ID替换为您的项目 ID。name: projects/PROJECT_ID/policies/custom.enforceTCPHealthCheckPort1024 spec: rules: – enforce: true
强制执行该政策:
gcloud org-policies set-policy enforceTCPHealthCheckPort1024-policy.yaml
尝试在禁止使用的 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.
健康检查
使用场景 语法 要求所有健康检查协议都在端口 1,024 或更高端口上进行 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 keepalive 超时值超过 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.
网址映射
使用场景 语法 要求网址映射具有针对 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
限制
不支持旧版健康检查(旧版全球 [HTTP] 和旧版全球 [HTTPS])。
对于某些 Compute Engine 资源(例如 Compute Engine SSL 政策资源),系统还会对
UPDATE方法强制执行自定义限制条件。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-10-19。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-10-19。"],[],[]] -