:doc:`EC2 <../../ec2>` / Client / replace_route

*************
replace_route
*************



.. py:method:: EC2.Client.replace_route(**kwargs)

  

  Replaces an existing route within a route table in a VPC.

   

  You must specify either a destination CIDR block or a prefix list ID. You must also specify exactly one of the resources from the parameter list, or reset the local route to its default target.

   

  For more information, see `Route tables <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html>`__ in the *Amazon VPC User Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/ReplaceRoute>`_  


  **Request Syntax**
  ::

    response = client.replace_route(
        DestinationPrefixListId='string',
        VpcEndpointId='string',
        LocalTarget=True|False,
        TransitGatewayId='string',
        LocalGatewayId='string',
        CarrierGatewayId='string',
        CoreNetworkArn='string',
        OdbNetworkArn='string',
        DryRun=True|False,
        RouteTableId='string',
        DestinationCidrBlock='string',
        GatewayId='string',
        DestinationIpv6CidrBlock='string',
        EgressOnlyInternetGatewayId='string',
        InstanceId='string',
        NetworkInterfaceId='string',
        VpcPeeringConnectionId='string',
        NatGatewayId='string'
    )
    
  :type DestinationPrefixListId: string
  :param DestinationPrefixListId: 

    The ID of the prefix list for the route.

    

  
  :type VpcEndpointId: string
  :param VpcEndpointId: 

    The ID of a VPC endpoint. Supported for Gateway Load Balancer endpoints only.

    

  
  :type LocalTarget: boolean
  :param LocalTarget: 

    Specifies whether to reset the local route to its default target ( ``local``).

    

  
  :type TransitGatewayId: string
  :param TransitGatewayId: 

    The ID of a transit gateway.

    

  
  :type LocalGatewayId: string
  :param LocalGatewayId: 

    The ID of the local gateway.

    

  
  :type CarrierGatewayId: string
  :param CarrierGatewayId: 

    [IPv4 traffic only] The ID of a carrier gateway.

    

  
  :type CoreNetworkArn: string
  :param CoreNetworkArn: 

    The Amazon Resource Name (ARN) of the core network.

    

  
  :type OdbNetworkArn: string
  :param OdbNetworkArn: 

    The Amazon Resource Name (ARN) of the ODB network.

    

  
  :type DryRun: boolean
  :param DryRun: 

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

    

  
  :type RouteTableId: string
  :param RouteTableId: **[REQUIRED]** 

    The ID of the route table.

    

  
  :type DestinationCidrBlock: string
  :param DestinationCidrBlock: 

    The IPv4 CIDR address block used for the destination match. The value that you provide must match the CIDR of an existing route in the table.

    

  
  :type GatewayId: string
  :param GatewayId: 

    The ID of an internet gateway or virtual private gateway.

    

  
  :type DestinationIpv6CidrBlock: string
  :param DestinationIpv6CidrBlock: 

    The IPv6 CIDR address block used for the destination match. The value that you provide must match the CIDR of an existing route in the table.

    

  
  :type EgressOnlyInternetGatewayId: string
  :param EgressOnlyInternetGatewayId: 

    [IPv6 traffic only] The ID of an egress-only internet gateway.

    

  
  :type InstanceId: string
  :param InstanceId: 

    The ID of a NAT instance in your VPC.

    

  
  :type NetworkInterfaceId: string
  :param NetworkInterfaceId: 

    The ID of a network interface.

    

  
  :type VpcPeeringConnectionId: string
  :param VpcPeeringConnectionId: 

    The ID of a VPC peering connection.

    

  
  :type NatGatewayId: string
  :param NatGatewayId: 

    [IPv4 traffic only] The ID of a NAT gateway.

    

  
  
  :returns: None

  **Examples**

  This example replaces the specified route in the specified table table. The new route matches the specified CIDR and sends the traffic to the specified virtual private gateway.
  ::

    response = client.replace_route(
        DestinationCidrBlock='10.0.0.0/16',
        GatewayId='vgw-9a4cacf3',
        RouteTableId='rtb-22574640',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'ResponseMetadata': {
            '...': '...',
        },
    }

  