title: AWS VPC Route Table - Change default route table
body: <p>Is it possible to change the route table associated with a VPC?  I am using CloudFormation and have created my own RT and associated subnets with it.  However, since the VPC is using the default route table and it claims that I have not explicitly associated the subnets, they are associated with the main route table as a catch all.  I am obviously doing something wrong as my subnets are associated with the route table I want, but the default route table seems to be taking precedence.</p>
  
  <p>This shows that the subnets are associated:</p>
  
  <p><a href="https://i.stack.imgur.com/o6rXh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o6rXh.png" alt="Shows that the subnets are associated"></a></p>
  
  <p>This says the subnets are not associated with a route table:</p>
  
  <p><a href="https://i.stack.imgur.com/f23AM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f23AM.png" alt="Says the subnets are not associated with a route table"></a></p>
  
  <p>If I add the IGW route to the default/main RT, everything works.  Not what I want though.</p>
  
  <p><em>Update</em></p>
  
  <p>Here is the CloudFormation to create the VPC and components.  The problem is that if a box is spun up in the subnet, the main route table is being used despite my subnets being explicitly associated with my custom route table.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Resources:
    TransitVPC:
      Type: 'AWS::EC2::VPC'
      Properties:
        CidrBlock: !Ref TransitVpcCidr
        EnableDnsSupport: 'true'
        EnableDnsHostnames: 'true'
        Tags:
        - Key: Name
          Value: Transit VPC
    TransitInternetGateway:
      Type: 'AWS::EC2::InternetGateway'
      Properties:
        Tags:
        - Key: Name
          Value: Transit Internet Gateway
      DependsOn:
      - TransitVPC
    TransitRouteTable:
      Type: 'AWS::EC2::RouteTable'
      Properties:
        VpcId: !Ref TransitVPC
        Tags:
        - Key: Name
          Value: Transit VPC RT
      DependsOn:
      - TransitVPC
    TransitIGWAttachment:
      Type: 'AWS::EC2::VPCGatewayAttachment'
      Properties:
        InternetGatewayId: !Ref TransitInternetGateway
        VpcId: !Ref TransitVPC
      DependsOn:
        - TransitVPC
        - TransitInternetGateway
    TransitSubnetA:
      Type: 'AWS::EC2::Subnet'
      Properties:
        VpcId: !Ref TransitVPC
        CidrBlock: !Ref TransitSubnetACidr
        AvailabilityZone: !Ref TransitSubnetARegion
        Tags:
        - Key: Name
          Value: Transit VPC Subnet A
      DependsOn:
      - TransitVPC
    TransitSubnetARTAssoc:
      Type: 'AWS::EC2::SubnetRouteTableAssociation'
      Properties:
        RouteTableId: !Ref TransitRouteTable
        SubnetId: !Ref TransitSubnetA
    TransitSubnetB:
      Type: 'AWS::EC2::Subnet'
      Properties:
        VpcId: !Ref TransitVPC
        CidrBlock: !Ref TransitSubnetBCidr
        AvailabilityZone: !Ref TransitSubnetBRegion
        Tags:
        - Key: Name
          Value: Transit VPC Subnet B
    TransitSubnetBRTAssoc:
      Type: 'AWS::EC2::SubnetRouteTableAssociation'
      Properties:
        SubnetId: !Ref TransitSubnetB
        RouteTableId: !Ref TransitRouteTable
    TransitIGWRoute:
      Type: 'AWS::EC2::Route'
      Properties:
        RouteTableId: !Ref TransitRouteTable
        DestinationCidrBlock: !Ref FinalGatewayCidr
        GatewayId: !Ref TransitInternetGateway
      DependsOn:
      - TransitIGWAttachment</code></pre>
  </div>
  </div>
  </p>