Class: Bora::Stack
- Inherits:
-
Object
- Object
- Bora::Stack
- Defined in:
- lib/bora/stack.rb
Instance Method Summary collapse
- #create(options, &block) ⇒ Object
- #create_or_update(options, &block) ⇒ Object
- #delete(&block) ⇒ Object
- #diff(options) ⇒ Object
- #events ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(stack_name) ⇒ Stack
constructor
A new instance of Stack.
- #new_template(options, pretty = true) ⇒ Object
- #template(pretty = true) ⇒ Object
- #update(options, &block) ⇒ Object
Constructor Details
#initialize(stack_name) ⇒ Stack
Returns a new instance of Stack.
7 8 9 10 11 |
# File 'lib/bora/stack.rb', line 7 def initialize(stack_name) @stack_name = stack_name @cfn = Aws::CloudFormation::Client.new @processed_events = Set.new end |
Instance Method Details
#create(options, &block) ⇒ Object
13 14 15 |
# File 'lib/bora/stack.rb', line 13 def create(, &block) call_cfn_action(:create, , &block) end |
#create_or_update(options, &block) ⇒ Object
21 22 23 |
# File 'lib/bora/stack.rb', line 21 def create_or_update(, &block) exists? ? update(, &block) : create(, &block) end |
#delete(&block) ⇒ Object
25 26 27 |
# File 'lib/bora/stack.rb', line 25 def delete(&block) call_cfn_action(:delete, &block) end |
#diff(options) ⇒ Object
52 53 54 |
# File 'lib/bora/stack.rb', line 52 def diff() Diffy::Diff.new(template, new_template()) end |
#events ⇒ Object
29 30 31 32 33 |
# File 'lib/bora/stack.rb', line 29 def events return [] if ! events = @cfn.describe_stack_events({stack_name: .stack_id}).stack_events events.reverse.map { |e| Event.new(e) } end |
#exists? ⇒ Boolean
56 57 58 |
# File 'lib/bora/stack.rb', line 56 def exists? && .stack_status != 'DELETE_COMPLETE' end |
#new_template(options, pretty = true) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/bora/stack.rb', line 42 def new_template(, pretty = true) if [:template_body] template = [:template_body] template = JSON.pretty_generate(JSON.parse(template)) if pretty template else raise Exception("new_template not yet implemented for template_url stack option") end end |
#template(pretty = true) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/bora/stack.rb', line 35 def template(pretty = true) return if !exists? template = @cfn.get_template({stack_name: @stack_name}).template_body template = JSON.pretty_generate(JSON.parse(template)) if pretty template end |
#update(options, &block) ⇒ Object
17 18 19 |
# File 'lib/bora/stack.rb', line 17 def update(, &block) call_cfn_action(:update, , &block) end |