You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::EC2::RouteTable::Association
- Inherits:
-
Object
- Object
- AWS::EC2::RouteTable::Association
- Defined in:
- lib/aws/ec2/route_table/association.rb
Overview
Represents the association between a AWS::EC2::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
Instance Attribute Summary collapse
-
#association_id ⇒ String
(also: #id)
readonly
An identifier representing the association between the network ACL and subnet.
-
#main ⇒ Boolean
(also: #main?)
readonly
Returns true if this association is the main (default) association for all subnets within this route table's VPC.
-
#route_table ⇒ RouteTable
readonly
-
#subnet ⇒ Subnet?
readonly
Returns the subnet this association belongs.
Instance Method Summary collapse
-
#delete ⇒ nil
(also: #disassociate)
Deletes the association between the route table and the subnet.
Instance Attribute Details
#association_id ⇒ String (readonly) Also known as: id
Returns An identifier representing the association between the network ACL and subnet.
88 89 90 |
# File 'lib/aws/ec2/route_table/association.rb', line 88 def association_id @association_id end |
#main ⇒ Boolean (readonly) Also known as: main?
Returns true if this association is the main (default) association for all subnets within this route table's VPC.
103 104 105 |
# File 'lib/aws/ec2/route_table/association.rb', line 103 def main @main end |
#route_table ⇒ RouteTable (readonly)
93 94 95 |
# File 'lib/aws/ec2/route_table/association.rb', line 93 def route_table @route_table end |
#subnet ⇒ Subnet? (readonly)
Returns the subnet this association belongs. If this is the main (default) association, then this method returns nil.
98 99 100 |
# File 'lib/aws/ec2/route_table/association.rb', line 98 def subnet @subnet end |
Instance Method Details
#delete ⇒ nil Also known as: disassociate
Deletes the association between the route table and the subnet
109 110 111 112 113 |
# File 'lib/aws/ec2/route_table/association.rb', line 109 def delete route_table.client.disassociate_route_table( :association_id => association_id) nil end |