Class: Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/roark/stack.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Stack

Returns a new instance of Stack.



3
4
5
6
7
8
# File 'lib/roark/stack.rb', line 3

def initialize(args)
  @aws    = args[:aws]
  @name   = args[:name]
  @region = @aws.region
  @logger = Roark.logger
end

Instance Method Details

#create(args) ⇒ Object



10
11
12
13
14
15
# 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

#destroyObject



17
18
19
20
# File 'lib/roark/stack.rb', line 17

def destroy
  @logger.info "Destroying Cloud Formation stack '#{@name}'."
  destroy_stack.destroy @name
end

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/roark/stack.rb', line 22

def exists?
  stack_status.exists? @name
end

#in_progress?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/roark/stack.rb', line 26

def in_progress?
  status =~ /^CREATE_IN_PROGRESS$/
end

#instance_idObject



34
35
36
# File 'lib/roark/stack.rb', line 34

def instance_id
  outputs.find {|o| o.key == 'InstanceId'}.value
end

#success?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/roark/stack.rb', line 30

def success?
  status =~ /^CREATE_COMPLETE$/
end