AWS CloudFormation
User Guide (API Version 2010-05-15)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.

AWS::EC2::Route

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

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

Properties

DestinationCidrBlock

The 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: Yes

Type: String

Update requires: Replacement

GatewayId

The ID of a gateway 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 provide only one of the following: a GatewayId, InstanceId, 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 provide only one of the following: a GatewayId, InstanceId, NetworkInterfaceId, or VpcPeeringConnectionId.

Type: String

Update requires: No interruption

NetworkInterfaceId

Allows the routing of network interface IDs.

Required: Conditional. You must provide only one of the following: a GatewayId, InstanceId, 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 provide only one of the following: a GatewayId, InstanceId, 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, it returns the resource name.

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

Examples

Example Route with Gateway ID

{
   "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" }
         }
      }
   }
}        

Example Route with Instance ID

{
   "AWSTemplateFormatVersion" : "2010-09-09",
   "Resources" : {
      "myRoute" : {
         "Type" : "AWS::EC2::Route",
         "Properties" : {
            "RouteTableId" : { "Ref" : "myRouteTable" },
            "DestinationCidrBlock" : "0.0.0.0/0",
            "InstanceId" : { "Ref" : "myInstance" }
         }
      }
   }
}        

Example Route with Network Interface ID.

{
   "AWSTemplateFormatVersion" : "2010-09-09",
   "Resources" : {
      "myRoute" : {
         "Type" : "AWS::EC2::Route",
         "Properties" : {
            "RouteTableId" : { "Ref" : "myRouteTable" },
            "DestinationCidrBlock" : "0.0.0.0/0",
            "NetworkInterfaceId" : { "Ref" : "eni-1a2b3c4d" }
         }
      }
   }
}        

Example Route with VPC peering connection ID.

{
   "AWSTemplateFormatVersion" : "2010-09-09",
   "Resources" : {
      "myRoute" : {
         "Type" : "AWS::EC2::Route",
         "Properties" : {
            "RouteTableId" : { "Ref" : "myRouteTable" },
            "DestinationCidrBlock" : "0.0.0.0/0",
            "VpcPeeringConnectionId" : { "Ref" : "myVPCPeeringConnectionID" }
         }
      }
   }
}        

See Also