Class BackendService
A Backend Service defines a group of virtual machines that will serve traffic for load balancing. This resource is a global backend service, appropriate for external load balancing or self-managed internal load balancing. For managed internal load balancing, use a regional backend service instead.
Currently self-managed internal load balancing is only available in beta.
To get more information about BackendService, see:
- API documentation
- How-to Guides
- Official Documentation
Example Usage - Backend Service Basic
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var defaultHttpHealthCheck = new Gcp.Compute.HttpHealthCheck("defaultHttpHealthCheck", new Gcp.Compute.HttpHealthCheckArgs
{
RequestPath = "/",
CheckIntervalSec = 1,
TimeoutSec = 1,
});
var defaultBackendService = new Gcp.Compute.BackendService("defaultBackendService", new Gcp.Compute.BackendServiceArgs
{
HealthChecks =
{
defaultHttpHealthCheck.Id,
},
});
}
}
Inherited Members
Namespace: Pulumi.Gcp.Compute
Assembly: Pulumi.Gcp.dll
Syntax
public class BackendService : CustomResource
Constructors
View SourceBackendService(String, BackendServiceArgs, CustomResourceOptions)
Create a BackendService resource with the given unique name, arguments, and options.
Declaration
public BackendService(string name, BackendServiceArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| BackendServiceArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceAffinityCookieTtlSec
Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set to 0, the cookie is non-persistent and lasts only until the end of the browser session (or equivalent). The maximum allowed value for TTL is one day. When the load balancing scheme is INTERNAL, this field is not used.
Declaration
public Output<int?> AffinityCookieTtlSec { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
Backends
The set of backends that serve this BackendService. Structure is documented below.
Declaration
public Output<ImmutableArray<BackendServiceBackend>> Backends { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<BackendServiceBackend>> |
CdnPolicy
Cloud CDN configuration for this BackendService. Structure is documented below.
Declaration
public Output<BackendServiceCdnPolicy> CdnPolicy { get; }
Property Value
| Type | Description |
|---|---|
| Output<BackendServiceCdnPolicy> |
CircuitBreakers
Settings controlling the volume of connections to a backend service. This field is applicable only when the load_balancing_scheme is set to INTERNAL_SELF_MANAGED. Structure is documented below.
Declaration
public Output<BackendServiceCircuitBreakers> CircuitBreakers { get; }
Property Value
| Type | Description |
|---|---|
| Output<BackendServiceCircuitBreakers> |
ConnectionDrainingTimeoutSec
Time for which instance will be drained (not accept new connections, but still work to finish started).
Declaration
public Output<int?> ConnectionDrainingTimeoutSec { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Int32>> |
ConsistentHash
Consistent Hash-based load balancing can be used to provide soft session affinity based on HTTP headers, cookies or other properties. This load balancing policy is applicable only for HTTP connections. The affinity to a particular destination host will be lost when one or more hosts are added/removed from the destination service. This field specifies parameters that control consistent hashing. This field only applies if the load_balancing_scheme is set to INTERNAL_SELF_MANAGED. This field is only applicable when locality_lb_policy is set to MAGLEV or RING_HASH. Structure is documented below.
Declaration
public Output<BackendServiceConsistentHash> ConsistentHash { get; }
Property Value
| Type | Description |
|---|---|
| Output<BackendServiceConsistentHash> |
CreationTimestamp
Creation timestamp in RFC3339 text format.
Declaration
public Output<string> CreationTimestamp { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
CustomRequestHeaders
Headers that the HTTP/S load balancer should add to proxied requests.
Declaration
public Output<ImmutableArray<string>> CustomRequestHeaders { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Description
An optional description of this resource. Provide this property when you create the resource.
Declaration
public Output<string> Description { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
EnableCdn
If true, enable Cloud CDN for this BackendService.
Declaration
public Output<bool?> EnableCdn { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Fingerprint
Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking.
Declaration
public Output<string> Fingerprint { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
HealthChecks
The set of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. Currently at most one health check can be specified, and a health check is required. For internal load balancing, a URL to a HealthCheck resource must be specified instead.
Declaration
public Output<string> HealthChecks { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Iap
Settings for enabling Cloud Identity Aware Proxy Structure is documented below.
Declaration
public Output<BackendServiceIap> Iap { get; }
Property Value
| Type | Description |
|---|---|
| Output<BackendServiceIap> |
LoadBalancingScheme
Indicates whether the backend service will be used with internal or external load balancing. A backend service created for one type of load balancing cannot be used with the other.
Declaration
public Output<string> LoadBalancingScheme { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LocalityLbPolicy
The load balancing algorithm used within the scope of the locality. The possible values are - ROUND_ROBIN - This is a simple policy in which each healthy backend is selected in round robin order. LEAST_REQUEST - An O(1) algorithm which selects two random healthy hosts and picks the host which has fewer active requests. RING_HASH - The ring/modulo hash load balancer implements consistent hashing to backends. The algorithm has the property that the addition/removal of a host from a set of N hosts only affects 1/N of the requests. RANDOM - The load balancer selects a random healthy host. ORIGINAL_DESTINATION - Backend host is selected based on the client connection metadata, i.e., connections are opened to the same address as the destination address of the incoming connection before the connection was redirected to the load balancer. MAGLEV - used as a drop in replacement for the ring hash load balancer. Maglev is not as stable as ring hash but has faster table lookup build times and host selection times. For more information about Maglev, refer to https://ai.google/research/pubs/pub44824 This field is applicable only when the load_balancing_scheme is set to INTERNAL_SELF_MANAGED.
Declaration
public Output<string> LocalityLbPolicy { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LogConfig
This field denotes the logging options for the load balancer traffic served by this backend service. If logging is enabled, logs will be exported to Stackdriver. Structure is documented below.
Declaration
public Output<BackendServiceLogConfig> LogConfig { get; }
Property Value
| Type | Description |
|---|---|
| Output<BackendServiceLogConfig> |
Name
Name of the cookie.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
OutlierDetection
Settings controlling eviction of unhealthy hosts from the load balancing pool. This field is applicable only when the load_balancing_scheme is set to INTERNAL_SELF_MANAGED. Structure is documented below.
Declaration
public Output<BackendServiceOutlierDetection> OutlierDetection { get; }
Property Value
| Type | Description |
|---|---|
| Output<BackendServiceOutlierDetection> |
PortName
Name of backend port. The same name should appear in the instance groups referenced by this service. Required when the load balancing scheme is EXTERNAL.
Declaration
public Output<string> PortName { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Project
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Declaration
public Output<string> Project { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Protocol
The protocol this BackendService uses to communicate with backends. The default is HTTP. NOTE: HTTP2 is only valid for beta HTTP/2 load balancer types and may result in errors if used with the GA API.
Declaration
public Output<string> Protocol { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
SecurityPolicy
The security policy associated with this backend service.
Declaration
public Output<string> SecurityPolicy { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
SelfLink
The URI of the created resource.
Declaration
public Output<string> SelfLink { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
SessionAffinity
Type of session affinity to use. The default is NONE. Session affinity is not applicable if the protocol is UDP.
Declaration
public Output<string> SessionAffinity { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
TimeoutSec
How many seconds to wait for the backend before considering it a failed request. Default is 30 seconds. Valid range is [1, 86400].
Declaration
public Output<int> TimeoutSec { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
Methods
View SourceGet(String, Input<String>, BackendServiceState, CustomResourceOptions)
Get an existing BackendService resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static BackendService Get(string name, Input<string> id, BackendServiceState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| BackendServiceState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| BackendService |