blob: 12a48521e017d48a8dad83d76beabd03177e7df2 [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: |-
TcpRoute is the resource defining how TCP traffic should be routed by a Mesh/Gateway resource.
---
# google\_network\_services\_tcp\_route
TcpRoute is the resource defining how TCP traffic should be routed by a Mesh/Gateway resource.
~> **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 TcpRoute, see:
* [API documentation](https://cloud.google.com/traffic-director/docs/reference/network-services/rest/v1beta1/projects.locations.tcpRoutes)
* How-to Guides
* [Setup TCP Services](https://cloud.google.com/traffic-director/docs/set-up-tcp-route)
<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_tcp_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 Tcp Route Basic
```hcl
resource "google_compute_backend_service" "default" {
provider = google-beta
name = "my-backend-service"
health_checks = [google_compute_http_health_check.default.id]
}
resource "google_compute_http_health_check" "default" {
provider = google-beta
name = "backend-service-health-check"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
resource "google_network_services_tcp_route" "default" {
provider = google-beta
name = "my-tcp-route"
labels = {
foo = "bar"
}
description = "my description"
rules {
matches {
address = "10.0.0.1/32"
port = "8081"
}
action {
destinations {
service_name = google_compute_backend_service.default.id
weight = 1
}
original_destination = false
}
}
}
```
<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_tcp_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 Tcp Route Actions
```hcl
resource "google_compute_backend_service" "default" {
provider = google-beta
name = "my-backend-service"
health_checks = [google_compute_http_health_check.default.id]
}
resource "google_compute_http_health_check" "default" {
provider = google-beta
name = "backend-service-health-check"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
resource "google_network_services_tcp_route" "default" {
provider = google-beta
name = "my-tcp-route"
labels = {
foo = "bar"
}
description = "my description"
rules {
action {
destinations {
service_name = google_compute_backend_service.default.id
weight = 1
}
original_destination = false
}
}
}
```
<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_tcp_route_mesh_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 Tcp Route Mesh Basic
```hcl
resource "google_compute_backend_service" "default" {
provider = google-beta
name = "my-backend-service"
health_checks = [google_compute_http_health_check.default.id]
}
resource "google_compute_http_health_check" "default" {
provider = google-beta
name = "backend-service-health-check"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
resource "google_network_services_mesh" "default" {
provider = google-beta
name = "my-tcp-route"
labels = {
foo = "bar"
}
description = "my description"
}
resource "google_network_services_tcp_route" "default" {
provider = google-beta
name = "my-tcp-route"
labels = {
foo = "bar"
}
description = "my description"
meshes = [
google_network_services_mesh.default.id
]
rules {
matches {
address = "10.0.0.1/32"
port = "8081"
}
action {
destinations {
service_name = google_compute_backend_service.default.id
weight = 1
}
original_destination = false
}
}
}
```
<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_tcp_route_gateway_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 Tcp Route Gateway Basic
```hcl
resource "google_compute_backend_service" "default" {
provider = google-beta
name = "my-backend-service"
health_checks = [google_compute_http_health_check.default.id]
}
resource "google_compute_http_health_check" "default" {
provider = google-beta
name = "backend-service-health-check"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
resource "google_network_services_gateway" "default" {
provider = google-beta
name = "my-tcp-route"
labels = {
foo = "bar"
}
description = "my description"
scope = "my-scope"
type = "OPEN_MESH"
ports = [443]
}
resource "google_network_services_tcp_route" "default" {
provider = google-beta
name = "my-tcp-route"
labels = {
foo = "bar"
}
description = "my description"
gateways = [
google_network_services_gateway.default.id
]
rules {
matches {
address = "10.0.0.1/32"
port = "8081"
}
action {
destinations {
service_name = google_compute_backend_service.default.id
weight = 1
}
original_destination = false
}
}
}
```
## Argument Reference
The following arguments are supported:
* `rules` -
(Required)
Rules that define how traffic is routed and handled. At least one RouteRule must be supplied.
If there are multiple rules then the action taken will be the first rule to match.
Structure is [documented below](#nested_rules).
* `name` -
(Required)
Name of the TcpRoute resource.
<a name="nested_rules"></a>The `rules` block supports:
* `matches` -
(Optional)
RouteMatch defines the predicate used to match requests to a given action. Multiple match types are "OR"ed for evaluation.
If no routeMatch field is specified, this rule will unconditionally match traffic.
Structure is [documented below](#nested_matches).
* `action` -
(Required)
A detailed rule defining how to route traffic.
Structure is [documented below](#nested_action).
<a name="nested_matches"></a>The `matches` block supports:
* `address` -
(Required)
Must be specified in the CIDR range format. A CIDR range consists of an IP Address and a prefix length to construct the subnet mask.
By default, the prefix length is 32 (i.e. matches a single IP address). Only IPV4 addresses are supported. Examples: "10.0.0.1" - matches against this exact IP address. "10.0.0.0/8" - matches against any IP address within the 10.0.0.0 subnet and 255.255.255.0 mask. "0.0.0.0/0" - matches against any IP address'.
* `port` -
(Required)
Specifies the destination port to match against.
<a name="nested_action"></a>The `action` block supports:
* `destinations` -
(Optional)
The destination services to which traffic should be forwarded. At least one destination service is required.
Structure is [documented below](#nested_destinations).
* `original_destination` -
(Optional)
If true, Router will use the destination IP and port of the original connection as the destination of the request.
<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. This is computed as: weight/Sum(weights in this destination list). For non-zero values, there may be some epsilon from the exact proportion defined here depending on the precision an implementation supports.
If only one serviceName is specified and it has a weight greater than 0, 100% of the traffic is forwarded to that backend.
If weights are specified for any one service name, they need to be specified for all of them.
If weights are unspecified for all services, then, traffic is distributed in equal proportions to all of them.
- - -
* `labels` -
(Optional)
Set of label tags associated with the TcpRoute 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)
Meshes defines a list of meshes this TcpRoute is attached to, as one of the routing rules to route the requests served by the mesh.
Each mesh reference should match the pattern: projects/*/locations/global/meshes/<mesh_name>
The attached Mesh should be of a type SIDECAR
* `gateways` -
(Optional)
Gateways defines a list of gateways this TcpRoute is attached to, as one of the routing rules to route the requests served by the gateway.
Each gateway reference should match the pattern: projects/*/locations/global/gateways/<gateway_name>
* `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/tcpRoutes/{{name}}`
* `self_link` -
Server-defined URL of this resource.
* `create_time` -
Time the TcpRoute was created in UTC.
* `update_time` -
Time the TcpRoute 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
TcpRoute can be imported using any of these accepted formats:
* `projects/{{project}}/locations/global/tcpRoutes/{{name}}`
* `{{project}}/{{name}}`
* `{{name}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import TcpRoute using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/locations/global/tcpRoutes/{{name}}"
to = google_network_services_tcp_route.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), TcpRoute can be imported using one of the formats above. For example:
```
$ terraform import google_network_services_tcp_route.default projects/{{project}}/locations/global/tcpRoutes/{{name}}
$ terraform import google_network_services_tcp_route.default {{project}}/{{name}}
$ terraform import google_network_services_tcp_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).