google_network_services_grpc_route

GrpcRoute is the resource defining how gRPC traffic routed by a Mesh or Gateway resource is routed.

To get more information about GrpcRoute, see:

Open in Cloud Shell

Example Usage - Network Services Grpc Route Basic

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

Example Usage - Network Services Grpc Route Matches And Actions

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

Example Usage - Network Services Grpc Route Actions

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:

The rules block supports:

The matches block supports:

The headers block supports:

The method block supports:

The action block supports:

The destinations block supports:

The fault_injection_policy block supports:

The delay block supports:

The abort block supports:

The retry_policy 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

GrpcRoute can be imported using any of these accepted formats:

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}}

User Project Overrides

This resource supports User Project Overrides.