blob: d697ba34e6e242a3caae719fe1ac10b53bce1ad4 [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Network services"
description: |-
GrpcRoute is the resource defining how gRPC traffic routed by a Mesh or Gateway resource is routed.
---
# google\_network\_services\_grpc\_route
GrpcRoute is the resource defining how gRPC traffic routed by a Mesh or Gateway resource is routed.
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
To get more information about GrpcRoute, see:
* [API documentation](https://cloud.google.com/traffic-director/docs/reference/network-services/rest/v1beta1/projects.locations.grpcRoutes)
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=network_services_grpc_route_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Network Services Grpc Route Basic
```hcl
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
}
}
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=network_services_grpc_route_matches_and_actions&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Network Services Grpc Route Matches And Actions
```hcl
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
}
}
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=network_services_grpc_route_actions&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Network Services Grpc Route Actions
```hcl
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
}
}
}
}
```
## Argument Reference
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](#nested_rules).
* `name` -
(Required)
Name of the GrpcRoute resource.
<a name="nested_rules"></a>The `rules` block supports:
* `matches` -
(Optional)
Matches define conditions used for matching the rule against incoming gRPC requests.
Structure is [documented below](#nested_matches).
* `action` -
(Optional)
Required. A detailed rule defining how to route traffic.
Structure is [documented below](#nested_action).
<a name="nested_matches"></a>The `matches` block supports:
* `headers` -
(Optional)
Specifies a list of HTTP request headers to match against.
Structure is [documented below](#nested_headers).
* `method` -
(Optional)
A gRPC method to match against. If this field is empty or omitted, will match all methods.
Structure is [documented below](#nested_method).
<a name="nested_headers"></a>The `headers` block supports:
* `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`.
<a name="nested_method"></a>The `method` block supports:
* `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.
<a name="nested_action"></a>The `action` block supports:
* `destinations` -
(Optional)
The destination to which traffic should be forwarded.
Structure is [documented below](#nested_destinations).
* `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](#nested_fault_injection_policy).
* `timeout` -
(Optional)
Specifies the timeout for selected route.
* `retry_policy` -
(Optional)
Specifies the retry policy associated with this route.
Structure is [documented below](#nested_retry_policy).
<a name="nested_destinations"></a>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.
<a name="nested_fault_injection_policy"></a>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](#nested_delay).
* `abort` -
(Optional)
Specification of how client requests are aborted as part of fault injection before being sent to a destination.
Structure is [documented below](#nested_abort).
<a name="nested_delay"></a>The `delay` block supports:
* `fixed_delay` -
(Optional)
Specify a fixed delay before forwarding the request.
* `percentage` -
(Optional)
The percentage of traffic on which delay will be injected.
<a name="nested_abort"></a>The `abort` block supports:
* `http_status` -
(Optional)
The HTTP status code used to abort the request.
* `percentage` -
(Optional)
The percentage of traffic which will be aborted.
<a name="nested_retry_policy"></a>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.
## 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}}/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.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 30 minutes.
- `update` - Default is 30 minutes.
- `delete` - Default is 30 minutes.
## Import
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](https://developer.hashicorp.com/terraform/language/import) to import GrpcRoute using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/locations/global/grpcRoutes/{{name}}"
to = google_network_services_grpc_route.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).