Changing the Route Table Associated with a Subnet

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 associated 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.

Request sample
$ 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.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LinkRouteTableId": "rtbassoc-12345678"
}

Changing the Route Table Associated with a Subnet Using AWS CLI

To change the route table associated with a subnet, use the replace-route-table-association command following this syntax:

Request sample
$ 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 attributes 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 ID of the association between the subnet and the route table to replace.

  • route-table-id: The ID of the new route table to associate with the subnet.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The replace-route-table-association command returns the following element:

  • NewAssociationId: The ID of the association between the subnet and the new route table.

Result sample
{
    "NewAssociationId": "rtbassoc-abcd1234"
}

The route table associated with the subnet 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.