Skip to content
v2.277.0

HttpRouteSpecOptions Struct ​

Properties specific for HTTP Based Routes.

Example ​

ts
declare const router: appmesh.VirtualRouter;
declare const node: appmesh.VirtualNode;

router.addRoute('route-http2-retry', {
  routeSpec: appmesh.RouteSpec.http2({
    weightedTargets: [{ virtualNode: node }],
    retryPolicy: {
      // Retry if the connection failed
      tcpRetryEvents: [appmesh.TcpRetryEvent.CONNECTION_ERROR],
      // Retry if HTTP responds with a gateway error (502, 503, 504)
      httpRetryEvents: [appmesh.HttpRetryEvent.GATEWAY_ERROR],
      // Retry five times
      retryAttempts: 5,
      // Use a 1 second timeout per retry
      retryTimeout: Duration.seconds(1),
    },
  }),
});
python
# router: appmesh.VirtualRouter
# node: appmesh.VirtualNode


router.add_route("route-http2-retry",
    route_spec=appmesh.RouteSpec.http2(
        weighted_targets=[appmesh.WeightedTarget(virtual_node=node)],
        retry_policy=appmesh.HttpRetryPolicy(
            # Retry if the connection failed
            tcp_retry_events=[appmesh.TcpRetryEvent.CONNECTION_ERROR],
            # Retry if HTTP responds with a gateway error (502, 503, 504)
            http_retry_events=[appmesh.HttpRetryEvent.GATEWAY_ERROR],
            # Retry five times
            retry_attempts=5,
            # Use a 1 second timeout per retry
            retry_timeout=Duration.seconds(1)
        )
    )
)
java
VirtualRouter router;
VirtualNode node;


router.addRoute("route-http2-retry", RouteBaseProps.builder()
        .routeSpec(RouteSpec.http2(HttpRouteSpecOptions.builder()
                .weightedTargets(List.of(WeightedTarget.builder().virtualNode(node).build()))
                .retryPolicy(HttpRetryPolicy.builder()
                        // Retry if the connection failed
                        .tcpRetryEvents(List.of(TcpRetryEvent.CONNECTION_ERROR))
                        // Retry if HTTP responds with a gateway error (502, 503, 504)
                        .httpRetryEvents(List.of(HttpRetryEvent.GATEWAY_ERROR))
                        // Retry five times
                        .retryAttempts(5)
                        // Use a 1 second timeout per retry
                        .retryTimeout(Duration.seconds(1))
                        .build())
                .build()))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualRouter router;
VirtualNode node;


router.AddRoute("route-http2-retry", new RouteBaseProps {
    RouteSpec = RouteSpec.Http2(new HttpRouteSpecOptions {
        WeightedTargets = new [] { new WeightedTarget { VirtualNode = node } },
        RetryPolicy = new HttpRetryPolicy {
            // Retry if the connection failed
            TcpRetryEvents = new [] { TcpRetryEvent.CONNECTION_ERROR },
            // Retry if HTTP responds with a gateway error (502, 503, 504)
            HttpRetryEvents = new [] { HttpRetryEvent.GATEWAY_ERROR },
            // Retry five times
            RetryAttempts = 5,
            // Use a 1 second timeout per retry
            RetryTimeout = Duration.Seconds(1)
        }
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var router VirtualRouter
var node VirtualNode


router.addRoute(jsii.String("route-http2-retry"), &RouteBaseProps{
	RouteSpec: appmesh.RouteSpec_Http2(&HttpRouteSpecOptions{
		WeightedTargets: []WeightedTarget{
			&WeightedTarget{
				VirtualNode: node,
			},
		},
		RetryPolicy: &HttpRetryPolicy{
			// Retry if the connection failed
			TcpRetryEvents: []cONNECTION_ERROR{
				appmesh.TcpRetryEvent_*cONNECTION_ERROR,
			},
			// Retry if HTTP responds with a gateway error (502, 503, 504)
			HttpRetryEvents: []HttpRetryEvent{
				appmesh.HttpRetryEvent_GATEWAY_ERROR,
			},
			// Retry five times
			RetryAttempts: jsii.Number(5),
			// Use a 1 second timeout per retry
			RetryTimeout: awscdk.Duration_Seconds(jsii.Number(1)),
		},
	}),
})

Properties ​

matchoptionalHttpRouteMatchmatchoptionalHttpRouteMatchmatchoptionalHttpRouteMatchMatchoptionalHttpRouteMatchMatchoptionalHttpRouteMatch #
The criterion for determining a request match for this Route.

Default: matches on '/'

priorityoptionalnumberpriorityoptionalint | floatpriorityoptionalNumberPriorityoptionaldoublePriorityoptional*float64 #
The priority for the route.

Default: no particular priority

When a Virtual Router has multiple routes, route match is performed in the order of specified value, where 0 is the highest priority, and first matched route is selected.

retryPolicyoptionalHttpRetryPolicyretry_policyoptionalHttpRetryPolicyretryPolicyoptionalHttpRetryPolicyRetryPolicyoptionalHttpRetryPolicyRetryPolicyoptionalHttpRetryPolicy #
The retry policy.

Default: no retry policy

timeoutoptionalHttpTimeouttimeoutoptionalHttpTimeouttimeoutoptionalHttpTimeoutTimeoutoptionalHttpTimeoutTimeoutoptionalHttpTimeout = None #
An object that represents a http timeout.
weightedTargetsWeightedTarget[]weighted_targetstyping.List[WeightedTarget]weightedTargetsList<WeightedTarget>WeightedTargetsWeightedTarget[]WeightedTargets*[]WeightedTarget required #
List of targets that traffic is routed to when a request matches the route.