| Did this page help you? Yes No Tell us about it... |
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.
| Name | Description | Required |
|---|---|---|
|
|
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 |
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 |
Conditional |
|
|
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 |
Conditional |
The elements in the following table are wrapped in a
CreateRouteResponse structure.
| Name | Description |
|---|---|
|
|
The ID of the request. Type: String |
|
|
Returns true if the request succeeds. Otherwise, returns an error. Type: xsd:boolean |
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
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
<CreateRouteResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </CreateRouteResponse>