AddRouteOptions

class aws_cdk.aws_ec2.AddRouteOptions(*, router_id, router_type, destination_cidr_block=None, destination_ipv6_cidr_block=None, enables_internet_connectivity=None)

Bases: object

Options for adding a new route to a subnet.

Parameters:
  • router_id (str) – The ID of the router. Can be an instance ID, gateway ID, etc, depending on the router type.

  • router_type (RouterType) – What type of router to route this traffic to.

  • destination_cidr_block (Optional[str]) – IPv4 range this route applies to. Default: ‘0.0.0.0/0’

  • destination_ipv6_cidr_block (Optional[str]) – IPv6 range this route applies to. Default: - Uses IPv6

  • enables_internet_connectivity (Optional[bool]) – Whether this route will enable internet connectivity. If true, this route will be added before any AWS resources that depend on internet connectivity in the VPC will be created. Default: false

ExampleMetadata:

infused

Example:

vpc = ec2.Vpc(self, "VPC",
    subnet_configuration=[ec2.SubnetConfiguration(
        subnet_type=ec2.SubnetType.PUBLIC,
        name="Public"
    ), ec2.SubnetConfiguration(
        subnet_type=ec2.SubnetType.PRIVATE_ISOLATED,
        name="Isolated"
    )]
)

(vpc.isolated_subnets[0]).add_route("StaticRoute",
    router_id=vpc.internet_gateway_id,
    router_type=ec2.RouterType.GATEWAY,
    destination_cidr_block="8.8.8.8/32"
)

Attributes

destination_cidr_block

IPv4 range this route applies to.

Default:

‘0.0.0.0/0’

destination_ipv6_cidr_block

IPv6 range this route applies to.

Default:
  • Uses IPv6

enables_internet_connectivity

Whether this route will enable internet connectivity.

If true, this route will be added before any AWS resources that depend on internet connectivity in the VPC will be created.

Default:

false

router_id

The ID of the router.

Can be an instance ID, gateway ID, etc, depending on the router type.

router_type

What type of router to route this traffic to.