module Convection::DSL::Template::Resource::EC2VPC

DSL For VPC sub-entities

Public Instance Methods

add_internet_gateway(&block) click to toggle source
# File lib/convection/model/template/resource/aws_ec2_vpc.rb, line 14
def add_internet_gateway(&block)
  g = Model::Template::Resource::EC2InternetGateway.new("#{ name }IG", @template)
  g.attach_to_vpc(self)
  g.tag('Name', "#{ name }InternetGateway")

  g.instance_exec(&block) if block
  @template.resources[g.name] = g

  ## Store the gateway for later reference
  @internet_gateway = g
end
add_network_acl(name, &block) click to toggle source
# File lib/convection/model/template/resource/aws_ec2_vpc.rb, line 26
def add_network_acl(name, &block)
  network_acl = Model::Template::Resource::EC2NetworkACL.new("#{ self.name }ACL#{ name }", @template)
  network_acl.vpc(self)
  network_acl.tag('Name', network_acl.name)

  network_acl.instance_exec(&block) if block
  @template.resources[network_acl.name] = network_acl
end
add_route_table(name, options = {}, &block) click to toggle source
# File lib/convection/model/template/resource/aws_ec2_vpc.rb, line 35
def add_route_table(name, options = {}, &block)
  route_table = Model::Template::Resource::EC2RouteTable.new("#{ self.name }Table#{ name }", @template)
  route_table.vpc(self)
  route_table.tag('Name', route_table.name)

  route_table.instance_exec(&block) if block

  @template.resources[route_table.name] = route_table
  return route_table unless options[:gateway_route]

  ## Create and associate an InterntGateway
  add_internet_gateway if @internet_gateway.nil?

  ## Create a route to the VPC's InternetGateway
  vpc_default_route = route_table.route('Default')
  vpc_default_route.destination('0.0.0.0/0')
  vpc_default_route.gateway(@internet_gateway)

  route_table
end
add_subnet(name, &block) click to toggle source
# File lib/convection/model/template/resource/aws_ec2_vpc.rb, line 56
def add_subnet(name, &block)
  s = Model::Template::Resource::EC2Subnet.new("#{ self.name }Subnet#{ name }", @template)
  s.tag('Name', s.name)
  s.vpc(self)

  ## Allocate the next available subnet
  @subnet_allocated += 1
  subnets = network.subnet(:Bits => @subnet_length,
                           :NumSubnets => @subnet_allocated)
  s.network(subnets[@subnet_allocated - 1])

  s.instance_exec(&block) if block
  @template.resources[s.name] = s
end