Class: Awshark::CloudFormation::Stack

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/awshark/cloud_formation/stack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ Stack

Returns a new instance of Stack.



31
32
33
34
# File 'lib/awshark/cloud_formation/stack.rb', line 31

def initialize(name:)
  @name = name
  @stack = get_stack(name)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/awshark/cloud_formation/stack.rb', line 13

def name
  @name
end

Instance Method Details

#create_or_update(params) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/awshark/cloud_formation/stack.rb', line 46

def create_or_update(params)
  if exists?
    client.update_stack(params)
  else
    client.create_stack(params)
  end
end

#eventsObject



41
42
43
44
# File 'lib/awshark/cloud_formation/stack.rb', line 41

def events
  response = client.describe_stack_events(stack_name: stack_id)
  response.stack_events
end

#exists?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/awshark/cloud_formation/stack.rb', line 37

def exists?
  @stack.present?
end

#reloadObject



54
55
56
57
58
# File 'lib/awshark/cloud_formation/stack.rb', line 54

def reload
  @stack = get_stack(name)

  self
end

#templateHash

Returns:

  • (Hash)


61
62
63
64
65
66
67
# File 'lib/awshark/cloud_formation/stack.rb', line 61

def template
  return nil unless exists?
  return @template if @template.present?

  response = client.get_template(stack_name: stack_id)
  @template = response.template_body
end