Amazon Elastic Compute Cloud
API Reference (API Version 2012-04-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

CreateRoute

Description

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.

When determining how to route traffic, we use the route with the most specific match. For example, let's say the traffic is destined for 192.0.2.3, and the route table includes the following two routes:

  • 192.0.2.0/24 (goes to some target A)

  • 192.0.2.0/28 (goes to some target B)

Both routes apply to the traffic destined for 192.0.2.3. However, the second route in the list covers a smaller number of IP addresses and is therefore more specific, so we use that route to determine where to target the traffic.

For more information about route tables, go to Route Tables in the Amazon Virtual Private Cloud User Guide.

Request Parameters

NameDescriptionRequired

RouteTableId

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

Type: String

Default: None

Yes

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.

Type: String

Default: None

Yes
GatewayId

The ID of a gateway attached to your VPC.

Type: String

Default: None

Condition: You must provide only one of the following: a GatewayID, InstanceID, or NetworkInterfaceId.

Conditional

InstanceId

The ID of a NAT instance in your VPC.

Type: String

Default: None

Condition: You must provide only one of the following: a GatewayID, InstanceID, or NetworkInterfaceId.

Conditional

NetworkInterfaceId

Allows the routing of network interface IDs. Exactly one interface must be attached when specifying an instance ID or it will fail.

Type: String

Default: None

Condition: You must provide only one of the following: a GatewayID, InstanceID, or NetworkInterfaceId.

Conditional

Response Elements

The elements in the following table are wrapped in a CreateRouteResponse structure.

NameDescription

requestId

The ID of the request.

Type: String

return

Returns true if the request succeeds. Otherwise, returns an error.

Type: xsd:boolean

Examples

Example Request

This example creates a route in the route table with ID rtb-e4ad488d. The route matches all traffic (0.0.0.0/0) and routes it to the Internet gateway with ID igw-eaad4883.

https://ec2.amazonaws.com/?Action=CreateRoute
&RouteTableId=rtb-e4ad488d
&DestinationCidrBlock=0.0.0.0/0
&GatewayId=igw-eaad4883
&AUTHPARAMS

Example Request

This example creates a route in the route table with ID rtb-g8ff4ea2. The route sends all traffic (0.0.0.0/0) to the NAT instance with ID i-1a2b3c4d.

https://ec2.amazonaws.com/?Action=CreateRoute
&RouteTableId=rtb-g8ff4ea2
&DestinationCidrBlock=0.0.0.0/0
&InstanceId=i-1a2b3c4d
&AUTHPARAMS

Example Response

<CreateRouteResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
   <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
   <return>true</return>
</CreateRouteResponse>