Sha256: 609d0aa7c8ac444b285a3f4c0aef04439a1a18d608d0757b4cb7b1fe5f904109

Contents?: true

Size: 1.08 KB

Versions: 176

Compression:

Stored size: 1.08 KB

Contents

RSpec::Matchers.define :belong_to_subnet do |subnet_id|
  match do |type|
    # EC2, NetworkInterface
    if type.instance_of?(Awspec::Type::Ec2) || type.instance_of?(Awspec::Type::NetworkInterface)
      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

176 entries across 176 versions & 4 rubygems

Version Path
cthiesfork-awspec-1.2.2 lib/awspec/matcher/belong_to_subnet.rb
cthiesfork-awspec-1.2.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.18.5 lib/awspec/matcher/belong_to_subnet.rb
cthiesfork-awspec-1.2.0 lib/awspec/matcher/belong_to_subnet.rb
cthiesfork-awspec-1.1.0 lib/awspec/matcher/belong_to_subnet.rb
cthiesfork-awspec-1.0.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.18.4 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.18.3 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.18.2 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.18.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.18.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.17.4 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.17.3 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.17.2 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.17.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.17.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.16.1 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.16.0 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.15.3 lib/awspec/matcher/belong_to_subnet.rb
awspec-1.15.2 lib/awspec/matcher/belong_to_subnet.rb