Skip to content

replace_route_table_association

replace_route_table_association(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    association_id: Optional[RouteTableAssociationId] = None,
    route_table_id: Optional[RouteTableId] = None,
) -> ReplaceRouteTableAssociationResult

Changes the route table associated with a given subnet, internet gateway, or virtual private gateway in a VPC. After the operation completes, the subnet or gateway uses the routes in the new route table. For more information about route tables, see Route tables in the Amazon VPC User Guide.

You can also use this operation to change which table is the main route table in the VPC. Specify the main route table's association ID and the route table ID of the new main route table.

Parameters:

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • association_id (Optional[RouteTableAssociationId], default: None ) –

    The association ID.

  • route_table_id (Optional[RouteTableId], default: None ) –

    The ID of the new route table to associate with the subnet.

Raises:

Examples:

To replace the route table associated with a subnet This example associates the specified route table with the subnet for the specified route table association.

>>> client.replace_route_table_association(association_id='rtbassoc-781d0d1a', route_table_id='rtb-22574640')
Source code in docs_src/capo_ec2/_services/ec2.py
def replace_route_table_association(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    association_id: Optional[
        "capo_ec2.types.route_table_association_id.RouteTableAssociationId"
    ] = None,
    route_table_id: Optional["capo_ec2.types.route_table_id.RouteTableId"] = None,
) -> "capo_ec2.types.replace_route_table_association_result.ReplaceRouteTableAssociationResult":
    """<p>Changes the route table associated with a given subnet, internet gateway, or virtual private gateway in a VPC. After the operation completes, the subnet or gateway uses the routes in the new route table. For more information about route tables, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html">Route tables</a> in the <i>Amazon VPC User Guide</i>.</p> <p>You can also use this operation to change which table is the main route table in the VPC. Specify the main route table's association ID and the route table ID of the new main route table.</p>

    Args:
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        association_id: <p>The association ID.</p>
        route_table_id: <p>The ID of the new route table to associate with the subnet.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To replace the route table associated with a subnet
        This example associates the specified route table with the subnet for the specified route table association.

        >>> client.replace_route_table_association(association_id='rtbassoc-781d0d1a', route_table_id='rtb-22574640')
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.replace_route_table_association_request.ReplaceRouteTableAssociationRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.replace_route_table_association_result.ReplaceRouteTableAssociationResult"
    ]:
        import capo_ec2._operations.amazon_ec2.replace_route_table_association

        output, http_response = (
            capo_ec2._operations.amazon_ec2.replace_route_table_association.replace_route_table_association(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ReplaceRouteTableAssociation")
    )
    input_: capo_ec2.types.replace_route_table_association_request.ReplaceRouteTableAssociationRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if association_id is not None:
        input_["association_id"] = association_id
    if route_table_id is not None:
        input_["route_table_id"] = route_table_id

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output