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
{ "Type" : "AWS::EC2::Route", "Properties" : { "DestinationCidrBlock" :String, "DestinationIpv6CidrBlock" :String, "EgressOnlyInternetGatewayId" :String, "GatewayId" :String, "InstanceId" :String, "NatGatewayId" :String, "NetworkInterfaceId" :String, "RouteTableId" :String, "VpcPeeringConnectionId" :String} }
YAML
Type: AWS::EC2::Route Properties: DestinationCidrBlock:StringDestinationIpv6CidrBlock:StringEgressOnlyInternetGatewayId:StringGatewayId:StringInstanceId:StringNatGatewayId:StringNetworkInterfaceId:StringRouteTableId:StringVpcPeeringConnectionId: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
DestinationCidrBlockorDestinationIpv6CidrBlockproperty.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
DestinationCidrBlockorDestinationIpv6CidrBlockproperty.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, orVpcPeeringConnectionId. 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, orVpcPeeringConnectionId.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, orVpcPeeringConnectionId.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, orVpcPeeringConnectionId.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, orVpcPeeringConnectionId.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, orVpcPeeringConnectionId.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
{ "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
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
-
CreateRoute in the Amazon EC2 API Reference
-
Route Tables in the Amazon VPC User Guide
