Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::EC2::Route

The AWS::EC2::Route resource creates a new route in a route table within a VPC. The route's target can be either a gateway attached to the VPC or a NAT instance in the VPC.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

Copy
{ "Type" : "AWS::EC2::Route", "Properties" : { "DestinationCidrBlock" : String, "DestinationIpv6CidrBlock" : String, "EgressOnlyInternetGatewayId" : String, "GatewayId" : String, "InstanceId" : String, "NatGatewayId" : String, "NetworkInterfaceId" : String, "RouteTableId" : String, "VpcPeeringConnectionId" : String } }

YAML

Copy
Type: "AWS::EC2::Route" Properties: DestinationCidrBlock: String DestinationIpv6CidrBlock: String EgressOnlyInternetGatewayId: String GatewayId: String InstanceId: String NatGatewayId: String NetworkInterfaceId: String RouteTableId: String VpcPeeringConnectionId: String

Properties

DestinationCidrBlock

The IPv4 CIDR address block used for the destination match. For example, 0.0.0.0/0. Routing decisions are based on the most specific match.

Required: Conditional. You must specify the DestinationCidrBlock or DestinationIpv6CidrBlock property.

Type: String

Update requires: Replacement

DestinationIpv6CidrBlock

The IPv6 CIDR address block used for the destination match. For example, ::/0. Routing decisions are based on the most specific match.

Required: Conditional. You must specify the DestinationCidrBlock or DestinationIpv6CidrBlock property.

Type: String

Update requires: Replacement

EgressOnlyInternetGatewayId

The ID of an egress-only internet gateway that is attached to your VPC (over IPv6 only).

Required: Conditional. You must specify only one of the following properties: EgressOnlyInternetGatewayId, GatewayId, InstanceId, NatGatewayId, NetworkInterfaceId, or VpcPeeringConnectionId. For an example that uses this property, see Amazon EC2 Route with Egress-Only Internet Gateway.

Type: String

Update requires: No interruption

GatewayId

The ID of an internet gateway or virtual private gateway that is attached to your VPC. For example: igw-eaad4883.

For route entries that specify a gateway, you must specify a dependency on the gateway attachment resource. For more information, see DependsOn Attribute.

Required: Conditional. You must specify only one of the following properties: EgressOnlyInternetGatewayId, GatewayId, InstanceId, NatGatewayId, NetworkInterfaceId, or VpcPeeringConnectionId.

Type: String

Update requires: No interruption

InstanceId

The ID of a NAT instance in your VPC. For example, i-1a2b3c4d.

Required: Conditional. You must specify only one of the following properties: EgressOnlyInternetGatewayId, GatewayId, InstanceId, NatGatewayId, NetworkInterfaceId, or VpcPeeringConnectionId.

Type: String

Update requires: No interruption

NatGatewayId

The ID of a NAT gateway. For example, nat-0a12bc456789de0fg.

Required: Conditional. You must specify only one of the following properties: EgressOnlyInternetGatewayId, GatewayId, InstanceId, NatGatewayId, NetworkInterfaceId, or VpcPeeringConnectionId.

Type: String

Update requires: No interruption

NetworkInterfaceId

Allows the routing of network interface IDs.

Required: Conditional. You must specify only one of the following properties: EgressOnlyInternetGatewayId, GatewayId, InstanceId, NatGatewayId, NetworkInterfaceId, or VpcPeeringConnectionId.

Type: String

Update requires: No interruption

RouteTableId

The ID of the route table where the route will be added.

Required: Yes

Type: String

Update requires: Replacement

VpcPeeringConnectionId

The ID of a VPC peering connection.

Required: Conditional. You must specify only one of the following properties: EgressOnlyInternetGatewayId, GatewayId, InstanceId, NatGatewayId, NetworkInterfaceId, or VpcPeeringConnectionId.

Type: String

Update requires: No interruption

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the resource name.

For more information about using the Ref function, see Ref.

Examples

The following example creates a route that is added to a gateway.

JSON

Copy
{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "myRoute" : { "Type" : "AWS::EC2::Route", "DependsOn" : "GatewayToInternet", "Properties" : { "RouteTableId" : { "Ref" : "myRouteTable" }, "DestinationCidrBlock" : "0.0.0.0/0", "GatewayId" : { "Ref" : "myInternetGateway" } } } } }

YAML

Copy
AWSTemplateFormatVersion: '2010-09-09' Resources: myRoute: Type: AWS::EC2::Route DependsOn: GatewayToInternet Properties: RouteTableId: Ref: myRouteTable DestinationCidrBlock: 0.0.0.0/0 GatewayId: Ref: myInternetGateway

More Info