Skip to content
v2.276.0

Experimental

@aws-cdk/aws-ec2-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

RouteTableProps Struct ​

Properties to define a route table.

Example ​

ts
const stack = new Stack();
const myVpc = new VpcV2(this, 'Vpc');
const vpnGateway = myVpc.enableVpnGatewayV2({
  vpnRoutePropagation: [{ subnetType: SubnetType.PUBLIC }],
  type: VpnConnectionType.IPSEC_1,
});

const routeTable = new RouteTable(stack, 'routeTable', {
  vpc: myVpc
  } );

new Route(stack, 'route', {
  destination: '172.31.0.0/24',
  target: { gateway: vpnGateway },
  routeTable: routeTable,
});
python
stack = Stack()
my_vpc = VpcV2(self, "Vpc")
vpn_gateway = my_vpc.enable_vpn_gateway_v2(
    vpn_route_propagation=[ec2.SubnetSelection(subnet_type=SubnetType.PUBLIC)],
    type=VpnConnectionType.IPSEC_1
)

route_table = RouteTable(stack, "routeTable",
    vpc=my_vpc
)

Route(stack, "route",
    destination="172.31.0.0/24",
    target={"gateway": vpn_gateway},
    route_table=route_table
)
java
Stack stack = new Stack();
VpcV2 myVpc = new VpcV2(this, "Vpc");
VPNGatewayV2 vpnGateway = myVpc.enableVpnGatewayV2(VPNGatewayV2Options.builder()
        .vpnRoutePropagation(List.of(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build()))
        .type(VpnConnectionType.IPSEC_1)
        .build());

RouteTable routeTable = RouteTable.Builder.create(stack, "routeTable")
        .vpc(myVpc)
        .build();

Route.Builder.create(stack, "route")
        .destination("172.31.0.0/24")
        .target(Map.of("gateway", vpnGateway))
        .routeTable(routeTable)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.ec2.Alpha
var stack = new Stack();
var myVpc = new VpcV2(this, "Vpc");
var vpnGateway = myVpc.EnableVpnGatewayV2(new VPNGatewayV2Options {
    VpnRoutePropagation = new [] { new SubnetSelection { SubnetType = SubnetType.PUBLIC } },
    Type = VpnConnectionType.IPSEC_1
});

var routeTable = new RouteTable(stack, "routeTable", new RouteTableProps {
    Vpc = myVpc
});

new Route(stack, "route", new RouteProps {
    Destination = "172.31.0.0/24",
    Target = new Dictionary<string, IRouteTarget?> { { "gateway", vpnGateway } },
    RouteTable = routeTable
});
go
// Install: go get github.com/aws/aws-cdk-go/awsec2alpha/v2
stack := awscdk.Newstack()
myVpc := awsec2alpha.NewVpcV2(this, jsii.String("Vpc"))
vpnGateway := myVpc.EnableVpnGatewayV2(&VPNGatewayV2Options{
	VpnRoutePropagation: []SubnetSelection{
		&SubnetSelection{
			SubnetType: awscdk.SubnetType_PUBLIC,
		},
	},
	Type: awscdk.VpnConnectionType_IPSEC_1,
})

routeTable := awsec2alpha.NewRouteTable(stack, jsii.String("routeTable"), &RouteTableProps{
	Vpc: myVpc,
})

awsec2alpha.NewRoute(stack, jsii.String("route"), &RouteProps{
	Destination: jsii.String("172.31.0.0/24"),
	Target: map[string]iRouteTarget{
		"gateway": vpnGateway,
	},
	RouteTable: routeTable,
})

Properties ​

routeTableNameoptionalstringroute_table_nameoptionalstrrouteTableNameoptionalStringRouteTableNameoptionalstringRouteTableNameoptional*string#
The resource name of the route table.

Default: provisioned without a route table name

vpcIVpcV2vpcIVpcV2vpcIVpcV2VpcIVpcV2VpcIVpcV2required#
The ID of the VPC.