Class: Phase::Adapters::AWS::Subnet

Inherits:
Phase::Adapters::Abstract::Base show all
Defined in:
lib/phase/adapters/aws/subnet.rb

Instance Attribute Summary

Attributes inherited from Phase::Adapters::Abstract::Base

#resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Phase::Adapters::Abstract::Base

#initialize

Constructor Details

This class inherits a constructor from Phase::Adapters::Abstract::Base

Class Method Details

.allArray<AWS::Subnet>

Returns All known subnets.

Returns:



16
17
18
# File 'lib/phase/adapters/aws/subnet.rb', line 16

def all
  where
end

.find(subnet_id) ⇒ AWS::Subnet?

Returns The requested subnet.

Parameters:

  • subnet_id (String)

    The ID of the requested subnet

Returns:



22
23
24
# File 'lib/phase/adapters/aws/subnet.rb', line 22

def find(subnet_id)
  new(api.subnets.get(subnet_id))
end

.where(options = {}) ⇒ Array<AWS::Subnet>

Returns All subnets matching the optional filters.

Parameters:

  • options (Hash) (defaults to: {})

    Filtering options

Options Hash (options):

  • :vpc_id (String)

    The ID of a VPC

  • :name (String)

    The value of the ‘Name’ tag

Returns:

  • (Array<AWS::Subnet>)

    All subnets matching the optional filters



30
31
32
33
34
35
36
37
# File 'lib/phase/adapters/aws/subnet.rb', line 30

def where(options = {})
  filters = {}

  filters["vpc-id"] = options[:vpc_id] if options[:vpc_id]
  filters["tag:Name"] = options[:name] if options[:name]

  api.subnets.all(filters).map {|subnet| new(subnet) }
end

Instance Method Details

#servers(options = {}) ⇒ Array<AWS::Server>

Returns The AWS instances within this VPC.

Parameters:

  • options (Hash) (defaults to: {})

    Filtering options

Returns:

  • (Array<AWS::Server>)

    The AWS instances within this VPC

See Also:



9
10
11
12
# File 'lib/phase/adapters/aws/subnet.rb', line 9

def servers(options = {})
  options[:subnet_id] = resource.subnet_id
  Server.where(options)
end