Class: CfFactory::CfVpc

Inherits:
Object
  • Object
show all
Includes:
CfBase
Defined in:
lib/cf_factory/vpc/cf_vpc.rb

Instance Method Summary collapse

Methods included from CfBase

#generate_ref, #get_deletion_policy, #get_name, #get_update_policy, #hash_to_string, #retrieve_attribute, #set_meta_data, #set_quotes, #set_tags

Constructor Details

#initialize(cidr, name = "MyVpc") ⇒ CfVpc

Returns a new instance of CfVpc.



7
8
9
10
11
12
13
14
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 7

def initialize(cidr, name = "MyVpc")
  @cidr = cidr
  @name = name
  @subnets = []
  @igws = []
  @route_tables = []
  @network_acls = []
end

Instance Method Details

#add_internet_gateway(igw) ⇒ Object



38
39
40
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 38

def add_internet_gateway(igw)
  @igws << igw
end

#add_network_acl(network_acl) ⇒ Object



42
43
44
45
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 42

def add_network_acl(network_acl)
  network_acl.set_vpc(self)
  @network_acls << network_acl
end

#add_route_table(route_table) ⇒ Object



33
34
35
36
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 33

def add_route_table(route_table)
  route_table.set_vpc(self)
  @route_tables << route_table
end

#add_subnet(subnet) ⇒ Object



28
29
30
31
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 28

def add_subnet(subnet)
  subnet.set_vpc(self)
  @subnets << subnet
end

#generateObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 47

def generate
  super
  @igws.each() {|ig|
    @result += ig.generate
  }
  @route_tables.each() {|rt|
    @result += rt.generate
  }
  @network_acls.each() {|acl|
    @result += acl.generate
  }
  @subnets.each() {|sn|
    @result += sn.generate
  }
  #
  @result        
end

#get_cf_attributesObject



20
21
22
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 20

def get_cf_attributes
  {}
end

#get_cf_propertiesObject



24
25
26
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 24

def get_cf_properties
  {"CidrBlock" => @cidr}
end

#get_cf_typeObject



16
17
18
# File 'lib/cf_factory/vpc/cf_vpc.rb', line 16

def get_cf_type
  "AWS::EC2::VPC"
end