google_compute_region_health_check

Health Checks determine whether instances are responsive and able to do work. They are an important part of a comprehensive load balancing configuration, as they enable monitoring instances behind load balancers.

Health Checks poll instances at a specified interval. Instances that do not respond successfully to some number of probes in a row are marked as unhealthy. No new connections are sent to unhealthy instances, though existing connections will continue. The health check will continue to poll unhealthy instances. If an instance later responds successfully to some number of consecutive probes, it is marked healthy again and can receive new connections.

To get more information about RegionHealthCheck, see:

Open in Cloud Shell

Example Usage - Region Health Check Tcp

resource "google_compute_region_health_check" "tcp-region-health-check" {
  name     = "tcp-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  tcp_health_check {
    port = "80"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Tcp Full

resource "google_compute_region_health_check" "tcp-region-health-check" {
  name        = "tcp-region-health-check"
  description = "Health check via tcp"

  timeout_sec         = 1
  check_interval_sec  = 1
  healthy_threshold   = 4
  unhealthy_threshold = 5

  tcp_health_check {
    port_name          = "health-check-port"
    port_specification = "USE_NAMED_PORT"
    request            = "ARE YOU HEALTHY?"
    proxy_header       = "NONE"
    response           = "I AM HEALTHY"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Ssl

resource "google_compute_region_health_check" "ssl-region-health-check" {
  name     = "ssl-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  ssl_health_check {
    port = "443"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Ssl Full

resource "google_compute_region_health_check" "ssl-region-health-check" {
  name        = "ssl-region-health-check"
  description = "Health check via ssl"

  timeout_sec         = 1
  check_interval_sec  = 1
  healthy_threshold   = 4
  unhealthy_threshold = 5

  ssl_health_check {
    port_name          = "health-check-port"
    port_specification = "USE_NAMED_PORT"
    request            = "ARE YOU HEALTHY?"
    proxy_header       = "NONE"
    response           = "I AM HEALTHY"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Http

resource "google_compute_region_health_check" "http-region-health-check" {
  name     = "http-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  http_health_check {
    port = "80"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Http Logs

resource "google_compute_region_health_check" "http-region-health-check" {
  provider = google-beta

  name = "http-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  http_health_check {
    port = "80"
  }

  log_config {
    enable = true
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Http Full

resource "google_compute_region_health_check" "http-region-health-check" {
  name        = "http-region-health-check"
  description = "Health check via http"

  timeout_sec         = 1
  check_interval_sec  = 1
  healthy_threshold   = 4
  unhealthy_threshold = 5

  http_health_check {
    port_name          = "health-check-port"
    port_specification = "USE_NAMED_PORT"
    host               = "1.2.3.4"
    request_path       = "/mypath"
    proxy_header       = "NONE"
    response           = "I AM HEALTHY"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Https

resource "google_compute_region_health_check" "https-region-health-check" {
  name     = "https-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  https_health_check {
    port = "443"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Https Full

resource "google_compute_region_health_check" "https-region-health-check" {
  name        = "https-region-health-check"
  description = "Health check via https"

  timeout_sec         = 1
  check_interval_sec  = 1
  healthy_threshold   = 4
  unhealthy_threshold = 5

  https_health_check {
    port_name          = "health-check-port"
    port_specification = "USE_NAMED_PORT"
    host               = "1.2.3.4"
    request_path       = "/mypath"
    proxy_header       = "NONE"
    response           = "I AM HEALTHY"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Http2

resource "google_compute_region_health_check" "http2-region-health-check" {
  name     = "http2-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  http2_health_check {
    port = "443"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Http2 Full

resource "google_compute_region_health_check" "http2-region-health-check" {
  name        = "http2-region-health-check"
  description = "Health check via http2"

  timeout_sec         = 1
  check_interval_sec  = 1
  healthy_threshold   = 4
  unhealthy_threshold = 5

  http2_health_check {
    port_name          = "health-check-port"
    port_specification = "USE_NAMED_PORT"
    host               = "1.2.3.4"
    request_path       = "/mypath"
    proxy_header       = "NONE"
    response           = "I AM HEALTHY"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Grpc

resource "google_compute_region_health_check" "grpc-region-health-check" {
  name = "grpc-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  grpc_health_check {
    port = "443"
  }
}
Open in Cloud Shell

Example Usage - Region Health Check Grpc Full

resource "google_compute_region_health_check" "grpc-region-health-check" {
  name = "grpc-region-health-check"

  timeout_sec        = 1
  check_interval_sec = 1

  grpc_health_check {
    port_name          = "health-check-port"
    port_specification = "USE_NAMED_PORT"
    grpc_service_name  = "testservice"
  }
}

Argument Reference

The following arguments are supported:


The http_health_check block supports:

The https_health_check block supports:

The tcp_health_check block supports:

The ssl_health_check block supports:

The http2_health_check block supports:

The grpc_health_check block supports:

The log_config block supports:

Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

RegionHealthCheck can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import RegionHealthCheck using one of the formats above. For example:

import {
  id = "projects/{{project}}/regions/{{region}}/healthChecks/{{name}}"
  to = google_compute_region_health_check.default
}

When using the terraform import command, RegionHealthCheck can be imported using one of the formats above. For example:

$ terraform import google_compute_region_health_check.default projects/{{project}}/regions/{{region}}/healthChecks/{{name}}
$ terraform import google_compute_region_health_check.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_region_health_check.default {{region}}/{{name}}
$ terraform import google_compute_region_health_check.default {{name}}

User Project Overrides

This resource supports User Project Overrides.