» 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.

  • 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.

» 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 {{name}}