Skip to main content

Route

Create a route and associate it to an internet gateway or NAT gateway.

Example code

Attach a route to an internet gateway

exports.createResources = () => [
{
type: "Route",
group: "EC2",
properties: ({}) => ({
DestinationCidrBlock: "0.0.0.0/0",
}),
dependencies: () => ({
routeTable: "route-table",
ig: "ig",
}),
},
];

Attach a route to a NAT gateway

exports.createResources = () => [
{
type: "Route",
group: "EC2",
properties: ({}) => ({
DestinationCidrBlock: "0.0.0.0/0",
}),
dependencies: () => ({
routeTable: "PrivateRouteTableUSEAST1D",
natGateway: "NATGateway",
}),
},
];

Attach a route to a VPC Endpoint

exports.createResources = () => [
{
type: "Route",
group: "EC2",
dependencies: () => ({
routeTable: "project-vpc-endpoint-rtb-private1-us-east-1a",
vpcEndpoint: "project-vpc-endpoint-vpce-s3",
}),
},
];

Use a prefix list

exports.createResources = () => [
{
type: "Route",
group: "EC2",
dependencies: ({}) => ({
routeTable: "vpc-default::rt-default",
ig: "ig-default",
prefixList: "my-prefix",
}),
},
];

Attach a route to an EC2 Instance

exports.createResources = () => [
{
type: "Route",
group: "EC2",
properties: ({}) => ({
DestinationCidrBlock: "0.0.0.0/0",
}),
dependencies: ({}) => ({
routeTable: "vpc-default::rt-default",
ec2Instance: "my-instance",
}),
},
];

Attach a route to a VPC Peering Connection

exports.createResources = () => [
{
type: "Route",
group: "EC2",
properties: ({}) => ({
DestinationCidrBlock: "10.0.0.0/16",
}),
dependencies: ({}) => ({
routeTable: "vpc-peer::rt-default",
vpcPeeringConnection: "vpc-peering::my-vpc::vpc-peer",
}),
},
];

Attach a route to a VPN Gateway

exports.createResources = () => [
{
type: "Route",
group: "EC2",
properties: ({}) => ({
DestinationCidrBlock: "192.168.0.0/16",
}),
dependencies: ({}) => ({
routeTable: "vpc-vpn::my-rt",
vpnGateway: "vpw",
}),
},
];

Examples

Properties

Dependencies

List

gc l -t EC2::Route
Listing resources on 1 provider: aws
✓ aws us-east-1
✓ Initialising
✓ Listing 13/13
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│ 4 EC2::Route from aws │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ name: vpc-default::rt-default::local::172.31.0.0/16 │
│ managedByUs: NO │
│ live: │
│ DestinationCidrBlock: 172.31.0.0/16 │
│ GatewayId: local │
│ Origin: CreateRouteTable │
│ State: active │
│ RouteTableId: rtb-19753867 │
│ │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ name: vpc-ec2-example::route-table::igw::0.0.0.0/0 │
│ managedByUs: Yes │
│ live: │
│ DestinationCidrBlock: 0.0.0.0/0 │
│ GatewayId: igw-0e01961b98c435457 │
│ Origin: CreateRoute │
│ State: active │
│ RouteTableId: rtb-0bc05587c5359f095 │
│ │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ name: vpc-ec2-example::route-table::local::10.1.0.0/16 │
│ managedByUs: NO │
│ live: │
│ DestinationCidrBlock: 10.1.0.0/16 │
│ GatewayId: local │
│ Origin: CreateRouteTable │
│ State: active │
│ RouteTableId: rtb-0bc05587c5359f095 │
│ │
├──────────────────────────────────────────────────────────────────────────────────────────────┤