# HttpRetryPolicy

HTTP retry policy.

- Source: [`aws-appmesh/lib/route-spec.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-appmesh/lib/route-spec.ts#L185)

## 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),
    },
  }),
});
```

## Properties

- `httpRetryEvents`: [HttpRetryEvent](/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.HttpRetryEvent.html)[] — Specify HTTP events on which to retry.

  **Default:** no retries for http events

  You must specify at least one value
  for at least one types of retry events.

- `retryAttempts`: number (required) — The maximum number of retry attempts.

- `retryTimeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) (required) — The timeout for each retry attempt.

- `tcpRetryEvents`: [TcpRetryEvent](/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.TcpRetryEvent.html)[] — TCP events on which to retry.

  **Default:** no retries for tcp events

  The event occurs before any processing of a
  request has started and is encountered when the upstream is temporarily or
  permanently unavailable. You must specify at least one value for at least
  one types of retry events.
