Changing the Route Table Association
You can change the route table that is associated with a Subnet. This action automatically modifies the way traffic is routed for virtual machines (VMs) in the Subnet, using the routes contained in the new route table.
You can also change the route table that is associated with a Net, in order to set the route table as main. It is then automatically applied to Subnets that are not explicitly associated with a route table.
Changing the Route Table Linked to a Subnet Using OSC CLI
The UpdateRouteTableLink command replaces the route table associated with a specific Subnet in a Net with another one.
After the route table is replaced, the Subnet uses the routes in the new route table it is associated with.
$ osc-cli api UpdateRouteTableLink --profile "default" \
--LinkRouteTableId "rtbassoc-12345678" \
--RouteTableId "rtb-12345678"
This command contains the following attributes that you need to specify:
-
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
LinkRouteTableId
: The ID of the current route table link. -
RouteTableId
: The ID of the new route table to associate with the Subnet.
The UpdateRouteTableLink command returns the following elements:
-
LinkRouteTableId
: The ID of the association between the route table and the Subnet. -
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"LinkRouteTableId": "rtbassoc-12345678"
}
Changing the Route Table Linked to a Subnet Using oapi-cli
The UpdateRouteTableLink command replaces the route table associated with a specific Subnet in a Net with another one.
After the route table is replaced, the Subnet uses the routes in the new route table it is associated with.
$ oapi-cli --profile "default" UpdateRouteTableLink \
--LinkRouteTableId "rtbassoc-12345678" \
--RouteTableId "rtb-12345678"
This command contains the following attributes that you need to specify:
-
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
LinkRouteTableId
: The ID of the current route table link. -
RouteTableId
: The ID of the new route table to associate with the Subnet.
The UpdateRouteTableLink command returns the following elements:
-
LinkRouteTableId
: The ID of the association between the route table and the Subnet. -
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"LinkRouteTableId": "rtbassoc-12345678"
}
Changing the Route Table Association Using AWS CLI
Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI. |
To change the route table associated with a Subnet or with a VPC, use the replace-route-table-association command following this syntax:
$ aws ec2 replace-route-table-association \
--profile YOUR_PROFILE \
--association-id rtbassoc-4321dcba \
--route-table-id rtb-1234abcd \
--endpoint https://fcu.eu-west-2.outscale.com
This command contains the following options that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
association-id
: The association ID of the current route table. For more information, see Getting Information About Your Route Tables. -
route-table-id
: The ID of the route table that you want to associate with the Subnet, or to set as main for the VPC. -
endpoint
: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.
The replace-route-table-association command returns the following element:
-
NewAssociationId
: The new association ID.
{
"NewAssociationId": "rtbassoc-abcd1234"
}
The current route table is replaced by the specified one.
Related Pages
Corresponding API Methods
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.