Sha256: 995575be18260269ac54b6d2e2e684c52fbfe372111ad312398317a965b257f2

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

module Awspec::Type
  class RouteTable < Base
    def initialize(id)
      super
      @resource = find_route_table(id)
      @id = @resource[:route_table_id] if @resource
    end

    def has_route?(destination, gateway_id = nil, instance_id = nil)
      @resource.routes.find do |route|
        if destination
          next false unless route.destination_cidr_block == destination
        end
        # * gateway
        next true if route.gateway_id == gateway_id
        # internet gateway
        igw = find_internet_gateway(gateway_id)
        next true if igw && igw.tag_name == gateway_id
        # virtual gateway
        vgw = find_virtual_gateway(gateway_id)
        next true if vgw && vgw.tag_name == gateway_id
        # customer gateway
        cgw = find_customer_gateway(gateway_id)
        next true if cgw && cgw.tag_name == gateway_id
        # instance
        next true if route.instance_id == instance_id
        instance = find_ec2(instance_id)
        next true if instance && instance.tag_name == instance_id
      end
    end

    def has_subnet?(subnet_id)
      subnet = find_subnet(subnet_id)
      return false unless subnet
      @resource.associations.find do |a|
        a[:subnet_id] == subnet[:subnet_id]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
awspec-0.21.4 lib/awspec/type/route_table.rb
awspec-0.21.3 lib/awspec/type/route_table.rb