Class: AwsDump::VPC

Inherits:
Hash
  • Object
show all
Defined in:
lib/aws_dump/vpc.rb

Instance Method Summary collapse

Constructor Details

#initialize(region, vpc) ⇒ VPC

Returns a new instance of VPC.



5
6
7
8
9
10
11
12
# File 'lib/aws_dump/vpc.rb', line 5

def initialize(region, vpc)
  @region = region
  @vpc = vpc
  self[:name] = vpc.tags["Name"]
  self[:instances] = instances.sort
  self[:security_groups] = security_groups.sort
  self[:rds_instances] = rds_instances
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
# File 'lib/aws_dump/vpc.rb', line 14

def <=>(other)
  self[:name] <=> other[:name]
end

#instancesObject



18
19
20
21
22
# File 'lib/aws_dump/vpc.rb', line 18

def instances
  @vpc.instances.collect do |instance|
    Instance.new(self, instance)
  end
end

#rds_instancesObject



30
31
32
33
34
35
36
37
# File 'lib/aws_dump/vpc.rb', line 30

def rds_instances
  rds = AWS::RDS.new(@region..options.merge(:region => @region[:name]))
  rds.instances.collect do |instance|
    unless instance.vpc_id == @vpc.id
      RDSInstance.new(self, instance)
    end
  end.compact
end

#security_groupsObject



24
25
26
27
28
# File 'lib/aws_dump/vpc.rb', line 24

def security_groups
  @vpc.security_groups.collect do |security_group|
    SecurityGroup.new(self, security_group)
  end.compact
end