google_network_services_tcp_route

TcpRoute is the resource defining how TCP traffic should be routed by a Mesh/Gateway resource.

To get more information about TcpRoute, see:

Open in Cloud Shell

Example Usage - Network Services Tcp Route Basic

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
    }
  }
}
Open in Cloud Shell

Example Usage - Network Services Tcp Route Actions

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
    }
  }
}
Open in Cloud Shell

Example Usage - Network Services Tcp Route Mesh Basic

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
    }
  }
}
Open in Cloud Shell

Example Usage - Network Services Tcp Route Gateway Basic

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:

The rules block supports:

The matches block supports:

The action block supports:

The destinations block supports:


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

TcpRoute can be imported using any of these accepted formats:

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

import {
  id = "projects/{{project}}/locations/global/tcpRoutes/{{name}}"
  to = google_network_services_tcp_route.default
}

When using the terraform import command, 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.