Skip to content

googleComputeTargetGrpcProxy

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:

Example Usage - Target Grpc Proxy Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeHealthCheckDefault =
  new google.computeHealthCheck.ComputeHealthCheck(this, "default", {
    check_interval_sec: 1,
    grpc_health_check: [
      {
        grpc_service_name: "testservice",
        port_name: "health-check-port",
        port_specification: "USE_NAMED_PORT",
      },
    ],
    name: "healthcheck",
    timeout_sec: 1,
  });
const googleComputeBackendServiceHome =
  new google.computeBackendService.ComputeBackendService(this, "home", {
    health_checks: [googleComputeHealthCheckDefault.id],
    load_balancing_scheme: "INTERNAL_SELF_MANAGED",
    name: "backend",
    port_name: "grpc",
    protocol: "GRPC",
    timeout_sec: 10,
  });
const googleComputeUrlMapUrlmap = new google.computeUrlMap.ComputeUrlMap(
  this,
  "urlmap",
  {
    default_service: googleComputeBackendServiceHome.id,
    description: "a description",
    host_rule: [
      {
        hosts: ["mysite.com"],
        path_matcher: "allpaths",
      },
    ],
    name: "urlmap",
    path_matcher: [
      {
        default_service: googleComputeBackendServiceHome.id,
        name: "allpaths",
        route_rules: [
          {
            header_action: [
              {
                request_headers_to_add: [
                  {
                    header_name: "AddSomethingElse",
                    header_value: "MyOtherValue",
                    replace: true,
                  },
                ],
                request_headers_to_remove: ["RemoveMe2"],
                response_headers_to_add: [
                  {
                    header_name: "AddMe",
                    header_value: "MyValue",
                    replace: false,
                  },
                ],
                response_headers_to_remove: ["RemoveMe3"],
              },
            ],
            match_rules: [
              {
                full_path_match: "a full path",
                header_matches: [
                  {
                    exact_match: "match this exactly",
                    header_name: "someheader",
                    invert_match: true,
                  },
                ],
                ignore_case: true,
                metadata_filters: [
                  {
                    filter_labels: [
                      {
                        name: "PLANET",
                        value: "MARS",
                      },
                    ],
                    filter_match_criteria: "MATCH_ANY",
                  },
                ],
                query_parameter_matches: [
                  {
                    name: "a query parameter",
                    present_match: true,
                  },
                ],
              },
            ],
            priority: 1,
            url_redirect: [
              {
                host_redirect: "A host",
                https_redirect: false,
                path_redirect: "some/path",
                redirect_response_code: "TEMPORARY_REDIRECT",
                strip_query: true,
              },
            ],
          },
        ],
      },
    ],
    test: [
      {
        host: "hi.com",
        path: "/home",
        service: googleComputeBackendServiceHome.id,
      },
    ],
  }
);
const googleComputeTargetGrpcProxyDefault =
  new google.computeTargetGrpcProxy.ComputeTargetGrpcProxy(this, "default_3", {
    name: "proxy",
    url_map: googleComputeUrlMapUrlmap.id,
    validate_for_proxyless: true,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeTargetGrpcProxyDefault.overrideLogicalId("default");

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 [aZ]([AZ09]*[aZ09])? 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.

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

  • urlMap - (Optional) URL to the UrlMap resource that defines the mapping from URL to the BackendService. The protocol field in the BackendService must be set to GRPC.

  • validateForProxyless - (Optional) If true, indicates that the BackendServices referenced by the urlMap may be accessed by gRPC applications without using a sidecar proxy. This will enable configuration checks on urlMap and its referenced BackendServices to not allow unsupported features. A gRPC application must use "xds:///" scheme in the target URI of the service it is connecting to. If false, indicates that the BackendServices referenced by the urlMap will be accessed by gRPC applications via a sidecar proxy. In this case, a gRPC application must not use "xds:///" scheme in the target URI of the service it is connecting to

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

Attributes Reference

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

  • id - an identifier for the resource with format projects/{{project}}/global/targetGrpcProxies/{{name}}

  • creationTimestamp - Creation timestamp in RFC3339 text format.

  • selfLinkWithId - Server-defined URL with id for the resource.

  • fingerprint - Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a TargetGrpcProxy. An up-to-date fingerprint must be provided in order to patch/update the TargetGrpcProxy; otherwise, the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve the TargetGrpcProxy. A base64-encoded string.

  • selfLink - The URI of the created resource.

Timeouts

This resource provides the following Timeouts configuration options:

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

Import

TargetGrpcProxy can be imported using any of these accepted formats:

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