Method: Awspec::Type::Subnet#associated_to?

Defined in:
lib/awspec/type/subnet.rb

#associated_to?(route_table_id) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/awspec/type/subnet.rb', line 16

def associated_to?(route_table_id)
  res = ec2_client.describe_route_tables({
                                           filters:
                                           [
                                             {
                                               name: 'association.subnet-id',
                                               values: [id]
                                             }
                                           ]
                                         })
  return false if res[:route_tables].empty?

  associated_route_table = res[:route_tables].first
  associated_route_table.route_table_id == route_table_id || associated_route_table.tag_name == route_table_id
end