:doc:`RouteTable <index>` / Action / associate_with_subnet

*********************
associate_with_subnet
*********************



.. py:method:: EC2.RouteTable.associate_with_subnet(**kwargs)

  

  Associates a subnet in your VPC or an internet gateway or virtual private gateway attached to your VPC with a route table in your VPC. This association causes traffic from the subnet or gateway to be routed according to the routes in the route table. The action returns an association ID, which you need in order to disassociate the route table later. A route table can be associated with multiple subnets.

   

  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/AssociateRouteTable>`_  


  **Request Syntax**
  ::

    route_table_association = route_table.associate_with_subnet(
        GatewayId='string',
        PublicIpv4Pool='string',
        DryRun=True|False,
        SubnetId='string',
        
    )
    
  :type GatewayId: string
  :param GatewayId: 

    The ID of the internet gateway or virtual private gateway.

    

  
  :type PublicIpv4Pool: string
  :param PublicIpv4Pool: 

    The ID of a public IPv4 pool. A public IPv4 pool is a pool of IPv4 addresses that you've brought to Amazon Web Services with BYOIP.

    

  
  :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 SubnetId: string
  :param SubnetId: 

    The ID of the subnet.

    

  
  
  :rtype: :py:class:`ec2.RouteTableAssociation`
  :returns: RouteTableAssociation resource
  