GrpcRoute is the resource defining how gRPC traffic routed by a Mesh or Gateway resource is routed.
To get more information about GrpcRoute, see:
resource "google_network_services_grpc_route" "default" {
provider = google-beta
name = "my-grpc-route"
labels = {
foo = "bar"
}
description = "my description"
hostnames = ["example"]
rules {
matches {
headers {
key = "key"
value = "value"
}
}
action {
retry_policy {
retry_conditions = ["cancelled"]
num_retries = 1
}
}
}
}
resource "google_network_services_grpc_route" "default" {
provider = google-beta
name = "my-grpc-route"
labels = {
foo = "bar"
}
description = "my description"
hostnames = ["example"]
rules {
matches {
headers {
key = "key"
value = "value"
}
}
matches {
headers {
key = "key"
value = "value"
}
method {
grpc_service = "foo"
grpc_method = "bar"
case_sensitive = true
}
}
action {
fault_injection_policy {
delay {
fixed_delay = "1s"
percentage = 1
}
abort {
http_status = 500
percentage = 1
}
}
retry_policy {
retry_conditions = ["cancelled"]
num_retries = 1
}
}
}
}
resource "google_network_services_grpc_route" "default" {
provider = google-beta
name = "my-grpc-route"
labels = {
foo = "bar"
}
description = "my description"
hostnames = ["example"]
rules {
action {
fault_injection_policy {
delay {
fixed_delay = "1s"
percentage = 1
}
abort {
http_status = 500
percentage = 1
}
}
retry_policy {
retry_conditions = ["cancelled"]
num_retries = 1
}
}
}
}
The following arguments are supported:
hostnames
-
(Required)
Required. Service hostnames with an optional port for which this route describes traffic.
rules
-
(Required)
Rules that define how traffic is routed and handled.
Structure is documented below.
name
-
(Required)
Name of the GrpcRoute resource.
matches
-
(Optional)
Matches define conditions used for matching the rule against incoming gRPC requests.
Structure is documented below.
action
-
(Optional)
Required. A detailed rule defining how to route traffic.
Structure is documented below.
headers
-
(Optional)
Specifies a list of HTTP request headers to match against.
Structure is documented below.
method
-
(Optional)
A gRPC method to match against. If this field is empty or omitted, will match all methods.
Structure is documented below.
key
-
(Required)
Required. The key of the header.
value
-
(Required)
Required. The value of the header.
type
-
(Optional)
The type of match.
Default value is EXACT
.
Possible values are: TYPE_UNSPECIFIED
, EXACT
, REGULAR_EXPRESSION
.
grpc_service
-
(Required)
Required. Name of the service to match against.
grpc_method
-
(Required)
Required. Name of the method to match against.
case_sensitive
-
(Optional)
Specifies that matches are case sensitive. The default value is true.
destinations
-
(Optional)
The destination to which traffic should be forwarded.
Structure is documented below.
fault_injection_policy
-
(Optional)
The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure.
Structure is documented below.
timeout
-
(Optional)
Specifies the timeout for selected route.
retry_policy
-
(Optional)
Specifies the retry policy associated with this route.
Structure is documented below.
The destinations
block supports:
service_name
-
(Optional)
The URL of a BackendService to route traffic to.
weight
-
(Optional)
Specifies the proportion of requests forwarded to the backend referenced by the serviceName field.
The fault_injection_policy
block supports:
delay
-
(Optional)
Specification of how client requests are delayed as part of fault injection before being sent to a destination.
Structure is documented below.
abort
-
(Optional)
Specification of how client requests are aborted as part of fault injection before being sent to a destination.
Structure is documented below.
fixed_delay
-
(Optional)
Specify a fixed delay before forwarding the request.
percentage
-
(Optional)
The percentage of traffic on which delay will be injected.
http_status
-
(Optional)
The HTTP status code used to abort the request.
percentage
-
(Optional)
The percentage of traffic which will be aborted.
The retry_policy
block supports:
retry_conditions
-
(Optional)
Specifies one or more conditions when this retry policy applies.
Each value may be one of: connect-failure
, refused-stream
, cancelled
, deadline-exceeded
, resource-exhausted
, unavailable
.
num_retries
-
(Optional)
Specifies the allowed number of retries.
labels
-
(Optional)
Set of label tags associated with the GrpcRoute resource.
Note: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field effective_labels
for all of the labels present on the resource.
description
-
(Optional)
A free-text description of the resource. Max length 1024 characters.
meshes
-
(Optional)
List of meshes this GrpcRoute is attached to, as one of the routing rules to route the requests served by the mesh.
gateways
-
(Optional)
List of gateways this GrpcRoute is attached to, as one of the routing rules to route the requests served by the gateway.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format projects/{{project}}/locations/global/grpcRoutes/{{name}}
self_link
-
Server-defined URL of this resource.
create_time
-
Time the GrpcRoute was created in UTC.
update_time
-
Time the GrpcRoute was updated in UTC.
terraform_labels
-
The combination of labels configured directly on the resource
and default labels configured on the provider.
effective_labels
-
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
This resource provides the following Timeouts configuration options:
create
- Default is 30 minutes.update
- Default is 30 minutes.delete
- Default is 30 minutes.GrpcRoute can be imported using any of these accepted formats:
projects/{{project}}/locations/global/grpcRoutes/{{name}}
{{project}}/{{name}}
{{name}}
In Terraform v1.5.0 and later, use an import
block to import GrpcRoute using one of the formats above. For example:
import {
id = "projects/{{project}}/locations/global/grpcRoutes/{{name}}"
to = google_network_services_grpc_route.default
}
When using the terraform import
command, GrpcRoute can be imported using one of the formats above. For example:
$ terraform import google_network_services_grpc_route.default projects/{{project}}/locations/global/grpcRoutes/{{name}}
$ terraform import google_network_services_grpc_route.default {{project}}/{{name}}
$ terraform import google_network_services_grpc_route.default {{name}}
This resource supports User Project Overrides.