Changer l’attachement de la route table

Vous pouvez changer la route table qui est attachée à un Subnet. Cette action modifie automatiquement la façon dont le trafic est routé pour les machines virtuelles (VM) dans le Subnet, utilisant les routes contenues dans la nouvelle route table.

Vous pouvez aussi changer la route table qui est attachée à un Net, afin de la définir comme route table principale du Net. Elle est alors automatiquement appliquée aux Subnets qui ne sont pas explicitement associés à une route table.

Changer la route table attachée à un Subnet avec 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.

    • RequestId: The ID of the request.

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

Changer la route table attachée à un Subnet avec 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.

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

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

Changer l’attachement de la route table avec AWS CLI

Avant de commencer : Installez et configurez AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

Pour changer la route table associée à un Subnet ou à un VPC, utilisez la commande replace-route-table-association en suivant cette syntaxe :

Exemple de requête
$ 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

Cette commande contient les options suivantes que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • association-id : L’ID d’association de la route table actuelle. Pour en savoir plus, voir Obtenir des informations sur vos route tables.

  • route-table-id : L’ID de la route table que vous souhaitez associer au Subnet, ou définir comme route table principale pour le VPC.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête. Pour en savoir plus, voir Installer et configurer AWS CLI.

La commande replace-route-table-association renvoie l’élément suivant :

  • NewAssociationId : Le nouvel ID d’association.

Exemple de résultat
{
    "NewAssociationId": "rtbassoc-abcd1234"
}

La route table actuelle est remplacée par celle que vous avez spécifiée.

Pages connexes

Méthodes API correspondantes

AWS™ et Amazon Web Services™ sont des marques de commerce d'Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.