» google_compute_region_backend_service

A Region Backend Service defines a regionally-scoped group of virtual machines that will serve traffic for load balancing.

Region backend services can only be used when using internal load balancing. For external load balancing, use a global backend service instead.

To get more information about RegionBackendService, see:

» Example Usage - Region Backend Service Basic

resource "google_compute_region_backend_service" "default" {
  name                            = "region-backend-service"
  region                          = "us-central1"
  health_checks                   = ["${google_compute_health_check.default.self_link}"]
  connection_draining_timeout_sec = 10
  session_affinity                = "CLIENT_IP"

resource "google_compute_health_check" "default" {
  name               = "health-check"
  check_interval_sec = 1
  timeout_sec        = 1

  tcp_health_check {
    port = "80"

» Argument Reference

The following arguments are supported:

  • name - (Required) Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

  • health_checks - (Required) The list of HealthChecks for checking the health of the backend service. Currently at most one health check can be specified, and a health check is required.

  • backend - (Optional) The list of backends that serve this RegionBackendService. Structure is documented below.

  • description - (Optional) An optional description of this resource.

  • failover_policy - (Optional, Beta) Policy for failovers. Structure is documented below.

  • protocol - (Optional) The protocol this BackendService uses to communicate with backends. The possible values are TCP and UDP, and the default is TCP.

  • session_affinity - (Optional) Type of session affinity to use. The default is NONE. Can be NONE, CLIENT_IP, CLIENT_IP_PROTO, or CLIENT_IP_PORT_PROTO. When the protocol is UDP, this field is not used.

  • region - (Optional) The Region in which the created backend service should reside. If it is not provided, the provider region is used.

  • timeout_sec - (Optional) How many seconds to wait for the backend before considering it a failed request. Default is 30 seconds. Valid range is [1, 86400].

  • connection_draining_timeout_sec - (Optional) Time for which instance will be drained (not accept new connections, but still work to finish started).

  • load_balancing_scheme - (Optional) This signifies what the ForwardingRule will be used for and can only be INTERNAL for RegionBackendServices

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The backend block supports:

  • description - (Optional) An optional description of this resource. Provide this property when you create the resource.

  • group - (Optional) The fully-qualified URL of an Instance Group. This defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. Note that you must specify an Instance Group resource using the fully-qualified URL, rather than a partial URL. The instance group must be within the same region as the BackendService.

  • failover - (Optional, Beta) This field designates whether this is a failover backend. More than one failover backend can be configured for a given BackendService.

The failover_policy block supports:

  • disable_connection_drain_on_failover - (Optional) On failover or failback, this field indicates whether connection drain will be honored. Setting this to true has the following effect: connections to the old active pool are not drained. Connections to the new active pool use the timeout of 10 min (currently fixed). Setting to false has the following effect: both old and new connections will have a drain timeout of 10 min. This can be set to true only if the protocol is TCP. The default is false.

  • drop_traffic_if_unhealthy - (Optional) This option is used only when no healthy VMs are detected in the primary and backup instance groups. When set to true, traffic is dropped. When set to false, new connections are sent across all VMs in the primary group. The default is false.

  • failover_ratio - (Optional) The value of the field must be in [0, 1]. If the ratio of the healthy VMs in the primary backend is at or below this number, traffic arriving at the load-balanced IP will be directed to the failover backend. In case where 'failoverRatio' is not set or all the VMs in the backup backend are unhealthy, the traffic will be directed back to the primary backend in the "force" mode, where traffic will be spread to the healthy VMs with the best effort, or to all VMs when no VM is healthy. This field is only used with l4 load balancing.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • fingerprint - Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking.
  • self_link - The URI of the created resource.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

RegionBackendService can be imported using any of these accepted formats:

$ terraform import google_compute_region_backend_service.default projects/{{project}}/regions/{{region}}/backendServices/{{name}}
$ terraform import google_compute_region_backend_service.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_region_backend_service.default {{region}}/{{name}}
$ terraform import google_compute_region_backend_service.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.