Skip to content

Resource: awsAppmeshRoute

Provides an AWS App Mesh route resource.

Example Usage

HTTP Routing

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.appmeshRoute.AppmeshRoute(this, "serviceb", {
  meshName: "${aws_appmesh_mesh.simple.id}",
  name: "serviceB-route",
  spec: {
    httpRoute: {
      action: {
        weightedTarget: [
          {
            virtualNode: "${aws_appmesh_virtual_node.serviceb1.name}",
            weight: 90,
          },
          {
            virtualNode: "${aws_appmesh_virtual_node.serviceb2.name}",
            weight: 10,
          },
        ],
      },
      match: {
        prefix: "/",
      },
    },
  },
  virtualRouterName: "${aws_appmesh_virtual_router.serviceb.name}",
});

HTTP Header Routing

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.appmeshRoute.AppmeshRoute(this, "serviceb", {
  meshName: "${aws_appmesh_mesh.simple.id}",
  name: "serviceB-route",
  spec: {
    httpRoute: {
      action: {
        weightedTarget: [
          {
            virtualNode: "${aws_appmesh_virtual_node.serviceb.name}",
            weight: 100,
          },
        ],
      },
      match: {
        header: [
          {
            match: {
              prefix: "123",
            },
            name: "clientRequestId",
          },
        ],
        method: "POST",
        prefix: "/",
        scheme: "https",
      },
    },
  },
  virtualRouterName: "${aws_appmesh_virtual_router.serviceb.name}",
});

Retry Policy

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.appmeshRoute.AppmeshRoute(this, "serviceb", {
  meshName: "${aws_appmesh_mesh.simple.id}",
  name: "serviceB-route",
  spec: {
    httpRoute: {
      action: {
        weightedTarget: [
          {
            virtualNode: "${aws_appmesh_virtual_node.serviceb.name}",
            weight: 100,
          },
        ],
      },
      match: {
        prefix: "/",
      },
      retryPolicy: {
        httpRetryEvents: ["server-error"],
        maxRetries: 1,
        perRetryTimeout: {
          unit: "s",
          value: 15,
        },
      },
    },
  },
  virtualRouterName: "${aws_appmesh_virtual_router.serviceb.name}",
});

TCP Routing

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.appmeshRoute.AppmeshRoute(this, "serviceb", {
  meshName: "${aws_appmesh_mesh.simple.id}",
  name: "serviceB-route",
  spec: {
    tcpRoute: {
      action: {
        weightedTarget: [
          {
            virtualNode: "${aws_appmesh_virtual_node.serviceb1.name}",
            weight: 100,
          },
        ],
      },
    },
  },
  virtualRouterName: "${aws_appmesh_virtual_router.serviceb.name}",
});

Argument Reference

The following arguments are supported:

  • name - (Required) Name to use for the route. Must be between 1 and 255 characters in length.
  • meshName - (Required) Name of the service mesh in which to create the route. Must be between 1 and 255 characters in length.
  • meshOwner - (Optional) AWS account ID of the service mesh's owner. Defaults to the account ID the AWS provider is currently connected to.
  • virtualRouterName - (Required) Name of the virtual router in which to create the route. Must be between 1 and 255 characters in length.
  • spec - (Required) Route specification to apply.
  • tags - (Optional) Map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

The spec object supports the following:

  • grpcRoute - (Optional) GRPC routing information for the route.
  • http2Route - (Optional) HTTP/2 routing information for the route.
  • httpRoute - (Optional) HTTP routing information for the route.
  • priority - (Optional) Priority for the route, between 0 and 1000. Routes are matched based on the specified value, where 0 is the highest priority.
  • tcpRoute - (Optional) TCP routing information for the route.

The grpcRoute object supports the following:

  • action - (Required) Action to take if a match is determined.
  • match - (Required) Criteria for determining an gRPC request match.
  • retryPolicy - (Optional) Retry policy.
  • timeout - (Optional) Types of timeouts.

The http2Route and httpRoute objects supports the following:

  • action - (Required) Action to take if a match is determined.
  • match - (Required) Criteria for determining an HTTP request match.
  • retryPolicy - (Optional) Retry policy.
  • timeout - (Optional) Types of timeouts.

The tcpRoute object supports the following:

  • action - (Required) Action to take if a match is determined.
  • timeout - (Optional) Types of timeouts.

The action object supports the following:

  • weightedTarget - (Required) Targets that traffic is routed to when a request matches the route. You can specify one or more targets and their relative weights with which to distribute traffic.

The timeout object supports the following:

  • idle - (Optional) Idle timeout. An idle timeout bounds the amount of time that a connection may be idle.

The idle object supports the following:

  • unit - (Required) Unit of time. Valid values: ms, s.
  • value - (Required) Number of time units. Minimum value of 0.

The grpcRoute's match object supports the following:

  • metadata - (Optional) Data to match from the gRPC request.
  • methodName - (Optional) Method name to match from the request. If you specify a name, you must also specify a serviceName.
  • serviceName - (Optional) Fully qualified domain name for the service to match from the request.
  • port- (Optional) The port number to match from the request.

The metadata object supports the following:

  • name - (Required) Name of the route. Must be between 1 and 50 characters in length.
  • invert - (Optional) If true, the match is on the opposite of the match criteria. Default is false.
  • match - (Optional) Data to match from the request.

The metadata's match object supports the following:

  • exact - (Optional) Value sent by the client must match the specified value exactly. Must be between 1 and 255 characters in length.
  • prefix - (Optional) Value sent by the client must begin with the specified characters. Must be between 1 and 255 characters in length.
  • port- (Optional) The port number to match from the request.
  • range- (Optional) Object that specifies the range of numbers that the value sent by the client must be included in.
  • regex - (Optional) Value sent by the client must include the specified characters. Must be between 1 and 255 characters in length.
  • suffix - (Optional) Value sent by the client must end with the specified characters. Must be between 1 and 255 characters in length.

The grpcRoute's retryPolicy object supports the following:

  • grpcRetryEvents - (Optional) List of gRPC retry events. Valid values: cancelled, deadlineExceeded, internal, resourceExhausted, unavailable.
  • httpRetryEvents - (Optional) List of HTTP retry events. Valid values: clientError (HTTP status code 409), gatewayError (HTTP status codes 502, 503, and 504), serverError (HTTP status codes 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, and 511), streamError (retry on refused stream).
  • maxRetries - (Required) Maximum number of retries.
  • perRetryTimeout - (Required) Per-retry timeout.
  • tcpRetryEvents - (Optional) List of TCP retry events. The only valid value is connectionError.

The grpcRoute's timeout object supports the following:

  • idle - (Optional) Idle timeout. An idle timeout bounds the amount of time that a connection may be idle.
  • perRequest - (Optional) Per request timeout.

The idle and perRequest objects support the following:

  • unit - (Required) Unit of time. Valid values: ms, s.
  • value - (Required) Number of time units. Minimum value of 0.

The http2Route and httpRoute's match object supports the following:

  • prefix - (Optional) Path with which to match requests. This parameter must always start with /, which by itself matches all requests to the virtual router service name.
  • port- (Optional) The port number to match from the request.
  • header - (Optional) Client request headers to match on.
  • method - (Optional) Client request header method to match on. Valid values: get, head, post, put, delete, connect, options, trace, patch.
  • path - (Optional) Client request path to match on.
  • queryParameter - (Optional) Client request query parameters to match on.
  • scheme - (Optional) Client request header scheme to match on. Valid values: http, https.

The match's path object supports the following:

  • exact - (Optional) The exact path to match on.
  • regex - (Optional) The regex used to match the path.

The match's queryParameter object supports the following:

  • name - (Required) Name for the query parameter that will be matched on.
  • match - (Optional) The query parameter to match on.

The queryParameter's match object supports the following:

  • exact - (Optional) The exact query parameter to match on.

The http2Route and httpRoute's retryPolicy object supports the following:

  • httpRetryEvents - (Optional) List of HTTP retry events. Valid values: clientError (HTTP status code 409), gatewayError (HTTP status codes 502, 503, and 504), serverError (HTTP status codes 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, and 511), streamError (retry on refused stream).
  • maxRetries - (Required) Maximum number of retries.
  • perRetryTimeout - (Required) Per-retry timeout.
  • tcpRetryEvents - (Optional) List of TCP retry events. The only valid value is connectionError.

You must specify at least one value for httpRetryEvents, or at least one value for tcpRetryEvents.

The http2Route and httpRoute's timeout object supports the following:

  • idle - (Optional) Idle timeout. An idle timeout bounds the amount of time that a connection may be idle.
  • perRequest - (Optional) Per request timeout.

The idle and perRequest objects support the following:

  • unit - (Required) Unit of time. Valid values: ms, s.
  • value - (Required) Number of time units. Minimum value of 0.

The perRetryTimeout object supports the following:

  • unit - (Required) Retry unit. Valid values: ms, s.
  • value - (Required) Retry value.

The weightedTarget object supports the following:

  • virtualNode - (Required) Virtual node to associate with the weighted target. Must be between 1 and 255 characters in length.
  • weight - (Required) Relative weight of the weighted target. An integer between 0 and 100.
  • port - (Optional) The targeted port of the weighted object.

The header object supports the following:

  • name - (Required) Name for the HTTP header in the client request that will be matched on.
  • invert - (Optional) If true, the match is on the opposite of the match method and value. Default is false.
  • match - (Optional) Method and value to match the header value sent with a request. Specify one match method.

The header's match object supports the following:

  • exact - (Optional) Header value sent by the client must match the specified value exactly.
  • prefix - (Optional) Header value sent by the client must begin with the specified characters.
  • port- (Optional) The port number to match from the request.
  • range- (Optional) Object that specifies the range of numbers that the header value sent by the client must be included in.
  • regex - (Optional) Header value sent by the client must include the specified characters.
  • suffix - (Optional) Header value sent by the client must end with the specified characters.

The range object supports the following:

  • end - (Required) End of the range.
  • start - (Requited) Start of the range.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - ID of the route.
  • arn - ARN of the route.
  • createdDate - Creation date of the route.
  • lastUpdatedDate - Last update date of the route.
  • resourceOwner - Resource owner's AWS account ID.
  • tagsAll - Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

App Mesh virtual routes can be imported using meshName and virtualRouterName together with the route's name, e.g.,

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