Resource: aws_appmesh_route

Provides an AWS App Mesh route resource.

Example Usage

HTTP Routing

resource "aws_appmesh_route" "serviceb" {
  name                = "serviceB-route"
  mesh_name           = aws_appmesh_mesh.simple.id
  virtual_router_name = aws_appmesh_virtual_router.serviceb.name

  spec {
    http_route {
      match {
        prefix = "/"
      }

      action {
        weighted_target {
          virtual_node = aws_appmesh_virtual_node.serviceb1.name
          weight       = 90
        }

        weighted_target {
          virtual_node = aws_appmesh_virtual_node.serviceb2.name
          weight       = 10
        }
      }
    }
  }
}

HTTP Header Routing

resource "aws_appmesh_route" "serviceb" {
  name                = "serviceB-route"
  mesh_name           = aws_appmesh_mesh.simple.id
  virtual_router_name = aws_appmesh_virtual_router.serviceb.name

  spec {
    http_route {
      match {
        method = "POST"
        prefix = "/"
        scheme = "https"

        header {
          name = "clientRequestId"

          match {
            prefix = "123"
          }
        }
      }

      action {
        weighted_target {
          virtual_node = aws_appmesh_virtual_node.serviceb.name
          weight       = 100
        }
      }
    }
  }
}

Retry Policy

resource "aws_appmesh_route" "serviceb" {
  name                = "serviceB-route"
  mesh_name           = aws_appmesh_mesh.simple.id
  virtual_router_name = aws_appmesh_virtual_router.serviceb.name

  spec {
    http_route {
      match {
        prefix = "/"
      }

      retry_policy {
        http_retry_events = [
          "server-error",
        ]
        max_retries = 1

        per_retry_timeout {
          unit  = "s"
          value = 15
        }
      }

      action {
        weighted_target {
          virtual_node = aws_appmesh_virtual_node.serviceb.name
          weight       = 100
        }
      }
    }
  }
}

TCP Routing

resource "aws_appmesh_route" "serviceb" {
  name                = "serviceB-route"
  mesh_name           = aws_appmesh_mesh.simple.id
  virtual_router_name = aws_appmesh_virtual_router.serviceb.name

  spec {
    tcp_route {
      action {
        weighted_target {
          virtual_node = aws_appmesh_virtual_node.serviceb1.name
          weight       = 100
        }
      }
    }
  }
}

Argument Reference

This resource supports the following arguments:

The spec object supports the following:

The grpc_route object supports the following:

The http2_route and http_route objects supports the following:

The tcp_route object supports the following:

The action object supports the following:

The timeout object supports the following:

The idle object supports the following:

The grpc_route's match object supports the following:

The metadata object supports the following:

The metadata's match object supports the following:

The grpc_route's retry_policy object supports the following:

The grpc_route's timeout object supports the following:

The idle and per_request objects support the following:

The http2_route and http_route's match object supports the following:

The match's path object supports the following:

The match's query_parameter object supports the following:

The query_parameter's match object supports the following:

The http2_route and http_route's retry_policy object supports the following:

You must specify at least one value for http_retry_events, or at least one value for tcp_retry_events.

The http2_route and http_route's timeout object supports the following:

The idle and per_request objects support the following:

The per_retry_timeout object supports the following:

The weighted_target object supports the following:

The header object supports the following:

The header's match object supports the following:

The range object supports the following:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import App Mesh virtual routes using mesh_name and virtual_router_name together with the route's name. For example:

import {
  to = aws_appmesh_route.serviceb
  id = "simpleapp/serviceB/serviceB-route"
}

Using terraform import, import App Mesh virtual routes using mesh_name and virtual_router_name together with the route's name. For example:

% terraform import aws_appmesh_route.serviceb simpleapp/serviceB/serviceB-route