Class: Serverspec::Type::AWS::EC2::Subnets

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/resources/ec2/subnets.rb

Overview

The Subnets class provides serverspec expectations for a collection of EC2::Subnet resources

Instance Method Summary collapse

Constructor Details

#initialize(subnets) ⇒ Subnets

Returns a new instance of Subnets



18
19
20
# File 'lib/resources/ec2/subnets.rb', line 18

def initialize(subnets)
  @subnets = subnets
end

Instance Method Details

#evenly_spread_across_minimum_az?(num_azs) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
# File 'lib/resources/ec2/subnets.rb', line 22

def evenly_spread_across_minimum_az?(num_azs)
  subnet_grouping_by_az = @subnets.group_by(&:availability_zone)
  return false if
    number_of_sizes_in_sub_arrays(subnet_grouping_by_az) != 1

  return false if
    subnet_grouping_by_az.size < num_azs

  true
end

#to_sString

Returns the string representation of EC2::Subnet

Returns:

  • (String)


35
36
37
# File 'lib/resources/ec2/subnets.rb', line 35

def to_s
  "EC2 Subnets: #{@subnets.map(&:id)}"
end