class Stack

Public Class Methods

new(args) click to toggle source
# File lib/roark/stack.rb, line 3
def initialize(args)
  @aws    = args[:aws]
  @name   = args[:name]
  @region = @aws.region
  @logger = Roark.logger
end

Public Instance Methods

create(args) click to toggle source
# File lib/roark/stack.rb, line 10
def create(args)
  @logger.info "Creating Cloud Formation stack '#{@name}' in '#{@region}'."
  create_stack.create :name       => @name,
                      :parameters => args[:parameters],
                      :template   => args[:template]
end
destroy() click to toggle source
# File lib/roark/stack.rb, line 17
def destroy
  @logger.info "Destroying Cloud Formation stack '#{@name}'."
  destroy_stack.destroy @name
end
exists?() click to toggle source
# File lib/roark/stack.rb, line 22
def exists?
  stack_status.exists? @name
end
in_progress?() click to toggle source
# File lib/roark/stack.rb, line 26
def in_progress?
  status =~ /^CREATE_IN_PROGRESS$/
end
instance_id() click to toggle source
# File lib/roark/stack.rb, line 34
def instance_id
  outputs.find {|o| o.key == 'InstanceId'}.value
end
success?() click to toggle source
# File lib/roark/stack.rb, line 30
def success?
  status =~ /^CREATE_COMPLETE$/
end

Private Instance Methods

create_stack() click to toggle source
# File lib/roark/stack.rb, line 48
def create_stack
  @create_stack ||= Roark::Aws::CloudFormation::CreateStack.new @aws
end
destroy_stack() click to toggle source
# File lib/roark/stack.rb, line 52
def destroy_stack
  @destroy_stack ||= Roark::Aws::CloudFormation::DestroyStack.new @aws
end
outputs() click to toggle source
# File lib/roark/stack.rb, line 44
def outputs
  stack_outputs.outputs @name
end
stack_outputs() click to toggle source
# File lib/roark/stack.rb, line 56
def stack_outputs
  @stack_outputs ||= Roark::Aws::CloudFormation::StackOutputs.new @aws
end
stack_status() click to toggle source
# File lib/roark/stack.rb, line 60
def stack_status
  @stack_status ||= Roark::Aws::CloudFormation::StackStatus.new @aws
end
status() click to toggle source
# File lib/roark/stack.rb, line 40
def status
  stack_status.status @name
end