Class AWS::EC2::RouteTable::Association
In: lib/aws/ec2/route_table/association.rb
Parent: Object

Represents the association between a {RouteTable} and a {Subnet}.

You can get a route table association 2 ways:

  • enumerating associations from a route table
  • Asking a subnet for its route table association

Enumerating Associations

Given a route table:

  route_table.associations.each do |assoc|
    if assoc.main? # main association does not have a subnet
      puts "#{assoc.id} : main association"
    else
      puts "#{assoc.id} : #{assoc.subnet.id}"
    end
  end

Getting a Subnet Route Table Association

All subnets are associated with a route table. If the association was never explicitly created, then they are associated by default with the main route table.

  subnet.route_table_association #=> AWS::EC2::RouteTable::Association

  subnet.route_table_association.main? #=> true/false

Creating and Replacing a Route Table Association

To replace a route table association start at the subnet end:

  subnet.route_table = some_other_route_table

If this route table is associated (by default) to the main route table via the main (default) association a new association is created. If it was previously associated directly to a different route table then that association will be repalced.

Deleting an Association

You can delete all but the main route table association. When you delete an association, the subnet becomes associated with the main route table.

  # delete all explicit route table associations -- as a result
  # all subnets will default to the main route table
  vpc.subnets.each do |subnet|
    assoc = subnet.route_table_association
    assoc.delete unless assoc.main?
  end

Methods

delete   disassociate   new  

External Aliases

association_id -> id
main -> main?

Attributes

association_id  [R]  @return [String] An identifier representing the association
  between the network ACL and subnet.
main  [R]  @return [Boolean] Returns true if this association is the main
  (default) association for all subnets within this route table's
  VPC.
route_table  [R]  @return [RouteTable]
subnet  [R]  @return [Subnet,nil] Returns the subnet this association belongs.
  If this is the main (default) association, then this method
  returns nil.

Public Class methods

Public Instance methods

Deletes the association between the route table and the subnet @return [nil]

disassociate()

Alias for delete

[Validate]