Skip to content
GitHubXDiscordRSS

ClientVpnRoute

Learn how to create, update, and manage AWS EC2 ClientVpnRoutes using Alchemy Cloud Control.

The ClientVpnRoute resource allows you to manage AWS EC2 ClientVpnRoutes that define the route information for a Client VPN endpoint.

Create a basic ClientVpnRoute with required properties and a description.

import AWS from "alchemy/aws/control";
const basicRoute = await AWS.EC2.ClientVpnRoute("basicRoute", {
ClientVpnEndpointId: "cvpn-endpoint-12345678",
TargetVpcSubnetId: "subnet-1234abcd",
DestinationCidrBlock: "10.0.1.0/24",
Description: "Route to the application subnet"
});

Configure a ClientVpnRoute with additional properties for better resource management.

const advancedRoute = await AWS.EC2.ClientVpnRoute("advancedRoute", {
ClientVpnEndpointId: "cvpn-endpoint-87654321",
TargetVpcSubnetId: "subnet-abcd1234",
DestinationCidrBlock: "10.0.2.0/24",
Description: "Advanced route for VPN clients",
adopt: true // Adopt existing resource instead of failing
});

Demonstrate the creation of multiple routes for different subnets.

const routeOne = await AWS.EC2.ClientVpnRoute("routeOne", {
ClientVpnEndpointId: "cvpn-endpoint-12345678",
TargetVpcSubnetId: "subnet-1234abcd",
DestinationCidrBlock: "10.0.3.0/24",
Description: "Route to subnet 1"
});
const routeTwo = await AWS.EC2.ClientVpnRoute("routeTwo", {
ClientVpnEndpointId: "cvpn-endpoint-12345678",
TargetVpcSubnetId: "subnet-5678efgh",
DestinationCidrBlock: "10.0.4.0/24",
Description: "Route to subnet 2"
});

Illustrate how to adjust the CIDR blocks for specific network configurations.

const adjustedRoute = await AWS.EC2.ClientVpnRoute("adjustedRoute", {
ClientVpnEndpointId: "cvpn-endpoint-12345678",
TargetVpcSubnetId: "subnet-90abcdef",
DestinationCidrBlock: "10.0.5.0/24",
Description: "Route to adjusted CIDR block"
});