Class: 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, #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.



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

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

Instance Method Details

#add_internet_gateway(igw) ⇒ Object



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

def add_internet_gateway(igw)
  @igws << igw
end

#add_network_acl(network_acl) ⇒ Object



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

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

#add_route_table(route_table) ⇒ Object



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

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

#add_subnet(subnet) ⇒ Object



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

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

#generateObject



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

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



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

def get_cf_attributes
  {}
end

#get_cf_propertiesObject



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

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

#get_cf_typeObject



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

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