Sha256: f847015fe8456f3a79b19c0e0665a37b1c38585f7b8b276ce3d8e13da1442d8f

Contents?: true

Size: 1.42 KB

Versions: 38

Compression:

Stored size: 1.42 KB

Contents

module Awspec::Type
  class Mq < ResourceBase
    def resource_via_client
      @resource_via_client ||= find_broker(@display_name)
    end

    def id
      @id ||= resource_via_client.broker_id if resource_via_client
    end

    STATES = %w(
      running reboot-in-progress creation-in-progress
      creation-failed deletion-in-progress
    )

    STATES.each do |state|
      define_method state.tr('-', '_') + '?' do
        resource_via_client.broker_state.downcase == state
      end
    end

    def has_security_group?(sg_id)
      return true if has_vpc_security_group_id?(sg_id)
      return true if has_vpc_security_group_name?(sg_id)
      return true if has_vpc_security_group_tag_name?(sg_id)
    end

    def has_tag?(tag_key, tag_value)
      @resource_via_client.tags do |tag|
        tag.key == tag_key && tag.value == tag_value
      end
    end

    private

    def has_vpc_security_group_id?(sg_id)
      sgs = @resource_via_client.security_groups
      sgs.find do |sg|
        sg == sg_id
      end
    end

    def has_vpc_security_group_name?(sg_id)
      res = select_security_group_by_group_name([sg_id])

      return false unless res.count == 1
      has_vpc_security_group_id?(res.first.group_id)
    end

    def has_vpc_security_group_tag_name?(sg_id)
      res = select_security_group_by_tag_name([sg_id])

      return false unless res.count == 1
      has_vpc_security_group_id?(res.first.group_id)
    end
  end
end

Version data entries

38 entries across 38 versions & 3 rubygems

Version Path
awspec-1.25.1 lib/awspec/type/mq.rb
awspec-1.25.0 lib/awspec/type/mq.rb
awspec-1.24.4 lib/awspec/type/mq.rb
awspec-1.24.3 lib/awspec/type/mq.rb
awspec-1.24.2 lib/awspec/type/mq.rb
awspec-1.24.1 lib/awspec/type/mq.rb
awspec-1.24.0 lib/awspec/type/mq.rb
awspec-1.23.0 lib/awspec/type/mq.rb
awspec-1.22.1 lib/awspec/type/mq.rb
awspec-1.22.0 lib/awspec/type/mq.rb
awspec-1.21.1 lib/awspec/type/mq.rb
awspec-1.21.0 lib/awspec/type/mq.rb
awspec-1.20.0 lib/awspec/type/mq.rb
awspec-1.19.2 lib/awspec/type/mq.rb
awspec-1.19.1 lib/awspec/type/mq.rb
awspec-1.19.0 lib/awspec/type/mq.rb
cthiesfork-awspec-1.2.4 lib/awspec/type/mq.rb
awspec-api_gateway_extended-1.2.4 lib/awspec/type/mq.rb
awspec-api_gateway_extended-1.2.3 lib/awspec/type/mq.rb
awspec-1.18.6 lib/awspec/type/mq.rb