Sha256: 0b6c65ee2281757b15add79486c6bcd6edb8382b8157392d09b51d500de18c22

Contents?: true

Size: 1.64 KB

Versions: 20

Compression:

Stored size: 1.64 KB

Contents

module Awspec::Type
  class Elb < Base
    def resource_via_client
      @resource_via_client ||= find_elb(@display_name)
    end

    def id
      @id = resource_via_client.load_balancer_name if resource_via_client
    end

    health_check_options = %w(
      target interval timeout
      unhealthy_threshold healthy_threshold
    )

    health_check_options.each do |option|
      define_method 'health_check_' + option do
        resource_via_client.health_check[option]
      end
    end

    def has_ec2?(id)
      ec2 = find_ec2(id)
      resource_via_client.instances.find do |instance|
        instance.instance_id = ec2.instance_id
      end if ec2
    end

    def has_security_group?(sg_id)
      sgs = resource_via_client.security_groups
      ret = sgs.find do |sg|
        sg == sg_id
      end
      return true if ret
      sg2 = find_security_group(sg_id)
      return false unless sg2.tag_name == sg_id || sg2.group_name == sg_id
      sgs.find do |sg|
        sg == sg2.group_name
      end
    end

    def has_subnet?(subnet_id)
      subnets = resource_via_client.subnets
      ret = subnets.find do |s|
        s == subnet_id
      end
      return true if ret
      res = find_subnet(subnet_id)
      ret = subnets.find do |s|
        s == res.subnet_id
      end
    end

    def has_listener?(protocol:, port:, instance_protocol:, instance_port:)
      resource_via_client.listener_descriptions.find do |desc|
        listener = desc.listener
        listener.protocol == protocol && listener.load_balancer_port == port && \
          listener.instance_protocol == instance_protocol && listener.instance_port == instance_port
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
awspec-0.66.1 lib/awspec/type/elb.rb
awspec-0.66.0 lib/awspec/type/elb.rb
awspec-0.65.2 lib/awspec/type/elb.rb
awspec-0.65.1 lib/awspec/type/elb.rb
awspec-0.65.0 lib/awspec/type/elb.rb
awspec-0.64.0 lib/awspec/type/elb.rb
awspec-0.63.1 lib/awspec/type/elb.rb
awspec-0.63.0 lib/awspec/type/elb.rb
awspec-0.62.1 lib/awspec/type/elb.rb
awspec-0.62.0 lib/awspec/type/elb.rb
awspec-0.61.1 lib/awspec/type/elb.rb
awspec-0.61.0 lib/awspec/type/elb.rb
awspec-0.60.1 lib/awspec/type/elb.rb
awspec-0.60.0 lib/awspec/type/elb.rb
awspec-0.59.0 lib/awspec/type/elb.rb
awspec-0.58.0 lib/awspec/type/elb.rb
awspec-0.57.1 lib/awspec/type/elb.rb
awspec-0.57.0 lib/awspec/type/elb.rb
awspec-0.56.1 lib/awspec/type/elb.rb
awspec-0.56.0 lib/awspec/type/elb.rb