> **Experimental**
>
> `@aws-cdk/aws-ec2-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# RouteTargetType

The gateway or endpoint targeted by the route.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/route.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts#L633)

## Example

```ts
const stack = new Stack();
const myVpc = new VpcV2(this, 'Vpc');
const routeTable = new RouteTable(this, 'RouteTable', {
  vpc: myVpc,
});
const subnet = new SubnetV2(this, 'Subnet', {
  vpc: myVpc,
  availabilityZone: 'eu-west-2a',
  ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
  subnetType: SubnetType.PRIVATE_ISOLATED });

const igw = new InternetGateway(this, 'IGW', {
  vpc: myVpc,
});
new Route(this, 'IgwRoute', {
  routeTable,
  destination: '0.0.0.0/0',
  target:  { gateway: igw },
});
```

## Initializer

```ts
new RouteTargetType(props: RouteTargetProps)
```

## Properties

- `endpoint`: [IVpcEndpoint](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpcEndpoint.html) — The endpoint route target.

  **Default:** target is not set to an endpoint, in this case a gateway is needed.

  This is used for targets such as
  VPC endpoints.

- `gateway`: [IRouteTarget](/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.IRouteTarget.html) — The gateway route target.

  **Default:** target is not set to a gateway, in this case an endpoint is needed.

  This is used for targets such as
  egress-only internet gateway or VPC peering connection.
