Sha256: 39076aa833da99d13266b410d4be320f99274f0cd684b4000176410afd03f583

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

RSpec::Matchers.define :belong_to_subnet do |subnet_id|
  match do |type|
    # EC2
    if type.instance_of?(Awspec::Type::Ec2)
      return true if type.subnet_id == subnet_id
      subnet = type.find_subnet(subnet_id)
      return false unless subnet
      return subnet[:subnet_id] == type.subnet_id
    end

    # RDS
    if type.instance_of?(Awspec::Type::Rds)
      subnets = type.resource_via_client[:db_subnet_group][:subnets]
      ret = subnets.find do |s|
        s[:subnet_identifier] == subnet_id
      end

      return ret[:subnet_availability_zone][:name] == type.availability_zone if ret

      res = type.ec2_client.describe_subnets({
                                               filters: [{ name: 'tag:Name', values: [subnet_id] }]
                                             })
      return false unless res
      ret = subnets.find do |s|
        s[:subnet_identifier] == res[:subnets][0][:subnet_id]
      end

      return ret[:subnet_availability_zone][:name] == type.availability_zone if ret
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
awspec-0.35.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.34.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.33.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.32.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.31.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.30.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.29.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.28.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.28.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.27.2 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.27.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.27.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.26.2 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.26.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-0.26.0 lib/awspec/matcher/belong_to_subnet.rb