google_compute_target_grpc_proxy

Represents a Target gRPC Proxy resource. A target gRPC proxy is a component of load balancers intended for load balancing gRPC traffic. Global forwarding rules reference a target gRPC proxy. The Target gRPC Proxy references a URL map which specifies how traffic routes to gRPC backend services.

To get more information about TargetGrpcProxy, see:

Open in Cloud Shell

Example Usage - Target Grpc Proxy Basic

resource "google_compute_target_grpc_proxy" "default" {
  name    = "proxy"
  url_map = google_compute_url_map.urlmap.id
  validate_for_proxyless = true
}


resource "google_compute_url_map" "urlmap" {
  name        = "urlmap"
  description = "a description"
  default_service = google_compute_backend_service.home.id
  host_rule {
    hosts        = ["mysite.com"]
    path_matcher = "allpaths"
  }
  path_matcher {
    name = "allpaths"
    default_service = google_compute_backend_service.home.id
    route_rules {
      priority = 1
      header_action {
        request_headers_to_remove = ["RemoveMe2"]
        request_headers_to_add {
          header_name = "AddSomethingElse"
          header_value = "MyOtherValue"
          replace = true
        }
        response_headers_to_remove = ["RemoveMe3"]
        response_headers_to_add {
          header_name = "AddMe"
          header_value = "MyValue"
          replace = false
        }
      }
      match_rules {
        full_path_match = "a full path"
        header_matches {
          header_name = "someheader"
          exact_match = "match this exactly"
          invert_match = true
        }
        ignore_case = true
        metadata_filters {
          filter_match_criteria = "MATCH_ANY"
          filter_labels {
            name = "PLANET"
            value = "MARS"
          }
        }
        query_parameter_matches {
          name = "a query parameter"
          present_match = true
        }
      }
      url_redirect {
        host_redirect = "A host"
        https_redirect = false
        path_redirect = "some/path"
        redirect_response_code = "TEMPORARY_REDIRECT"
        strip_query = true
      }
    }
  }
  test {
    service = google_compute_backend_service.home.id
    host    = "hi.com"
    path    = "/home"
  }
}
resource "google_compute_backend_service" "home" {
  name        = "backend"
  port_name   = "grpc"
  protocol    = "GRPC"
  timeout_sec = 10
  health_checks = [google_compute_health_check.default.id]
  load_balancing_scheme = "INTERNAL_SELF_MANAGED"
}
resource "google_compute_health_check" "default" {
  name               = "healthcheck"
  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:


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

TargetGrpcProxy can be imported using any of these accepted formats:

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

import {
  id = "projects/{{project}}/global/targetGrpcProxies/{{name}}"
  to = google_compute_target_grpc_proxy.default
}

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

$ terraform import google_compute_target_grpc_proxy.default projects/{{project}}/global/targetGrpcProxies/{{name}}
$ terraform import google_compute_target_grpc_proxy.default {{project}}/{{name}}
$ terraform import google_compute_target_grpc_proxy.default {{name}}

User Project Overrides

This resource supports User Project Overrides.