Class: Stackit::Stack
- Inherits:
-
Object
- Object
- Stackit::Stack
- Defined in:
- lib/stackit/stack.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
Returns the value of attribute capabilities.
-
#change_set_name ⇒ Object
Returns the value of attribute change_set_name.
-
#cloudformation ⇒ Object
Returns the value of attribute cloudformation.
-
#creation_time ⇒ Object
Returns the value of attribute creation_time.
-
#description ⇒ Object
Returns the value of attribute description.
-
#disable_rollback ⇒ Object
Returns the value of attribute disable_rollback.
-
#last_updated_time ⇒ Object
Returns the value of attribute last_updated_time.
-
#notification_arns ⇒ Object
Returns the value of attribute notification_arns.
-
#on_failure ⇒ Object
Returns the value of attribute on_failure.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#retain_resources ⇒ Object
Returns the value of attribute retain_resources.
-
#stack_id ⇒ Object
Returns the value of attribute stack_id.
-
#stack_name ⇒ Object
Returns the value of attribute stack_name.
-
#stack_policy_body ⇒ Object
Returns the value of attribute stack_policy_body.
-
#stack_policy_during_update_body ⇒ Object
Returns the value of attribute stack_policy_during_update_body.
-
#stack_policy_during_update_url ⇒ Object
Returns the value of attribute stack_policy_during_update_url.
-
#stack_policy_url ⇒ Object
Returns the value of attribute stack_policy_url.
-
#stack_status ⇒ Object
Returns the value of attribute stack_status.
-
#stack_status_reason ⇒ Object
Returns the value of attribute stack_status_reason.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#timeout_in_minutes ⇒ Object
Returns the value of attribute timeout_in_minutes.
-
#use_previous_template ⇒ Object
Returns the value of attribute use_previous_template.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #change_set_request_params ⇒ Object
- #create_stack_request_params ⇒ Object
- #delete_stack_request_params ⇒ Object
- #hydrate! ⇒ Object
-
#initialize(options = {}) ⇒ Stack
constructor
A new instance of Stack.
- #outputs ⇒ Object
- #resources ⇒ Object
- #update_stack_request_params ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Stack
Returns a new instance of Stack.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/stackit/stack.rb', line 27 def initialize( = {}) = .to_h.symbolize_keys! self.cloudformation = [:cloudformation] || Stackit.cloudformation self.stack_name = [:stack_name] self.description = [:description] self.parameters = [:parameters] self.disable_rollback = [:disable_rollback] self.notification_arns = [:notification_arns] self.timeout_in_minutes = [:timeout_in_minutes] self.capabilities = [:capabilities] self. = [:tags] self.on_failure = [:on_failure] self.use_previous_template = [:use_previous_template] self.retain_resources = [:retain_resources] self.change_set_name = [:change_set_name] end |
Instance Attribute Details
#capabilities ⇒ Object
Returns the value of attribute capabilities.
20 21 22 |
# File 'lib/stackit/stack.rb', line 20 def capabilities @capabilities end |
#change_set_name ⇒ Object
Returns the value of attribute change_set_name.
25 26 27 |
# File 'lib/stackit/stack.rb', line 25 def change_set_name @change_set_name end |
#cloudformation ⇒ Object
Returns the value of attribute cloudformation.
4 5 6 |
# File 'lib/stackit/stack.rb', line 4 def cloudformation @cloudformation end |
#creation_time ⇒ Object
Returns the value of attribute creation_time.
9 10 11 |
# File 'lib/stackit/stack.rb', line 9 def creation_time @creation_time end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/stackit/stack.rb', line 7 def description @description end |
#disable_rollback ⇒ Object
Returns the value of attribute disable_rollback.
13 14 15 |
# File 'lib/stackit/stack.rb', line 13 def disable_rollback @disable_rollback end |
#last_updated_time ⇒ Object
Returns the value of attribute last_updated_time.
10 11 12 |
# File 'lib/stackit/stack.rb', line 10 def last_updated_time @last_updated_time end |
#notification_arns ⇒ Object
Returns the value of attribute notification_arns.
19 20 21 |
# File 'lib/stackit/stack.rb', line 19 def notification_arns @notification_arns end |
#on_failure ⇒ Object
Returns the value of attribute on_failure.
22 23 24 |
# File 'lib/stackit/stack.rb', line 22 def on_failure @on_failure end |
#parameters ⇒ Object
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/stackit/stack.rb', line 8 def parameters @parameters end |
#retain_resources ⇒ Object
Returns the value of attribute retain_resources.
24 25 26 |
# File 'lib/stackit/stack.rb', line 24 def retain_resources @retain_resources end |
#stack_id ⇒ Object
Returns the value of attribute stack_id.
5 6 7 |
# File 'lib/stackit/stack.rb', line 5 def stack_id @stack_id end |
#stack_name ⇒ Object
Returns the value of attribute stack_name.
6 7 8 |
# File 'lib/stackit/stack.rb', line 6 def stack_name @stack_name end |
#stack_policy_body ⇒ Object
Returns the value of attribute stack_policy_body.
15 16 17 |
# File 'lib/stackit/stack.rb', line 15 def stack_policy_body @stack_policy_body end |
#stack_policy_during_update_body ⇒ Object
Returns the value of attribute stack_policy_during_update_body.
17 18 19 |
# File 'lib/stackit/stack.rb', line 17 def stack_policy_during_update_body @stack_policy_during_update_body end |
#stack_policy_during_update_url ⇒ Object
Returns the value of attribute stack_policy_during_update_url.
18 19 20 |
# File 'lib/stackit/stack.rb', line 18 def stack_policy_during_update_url @stack_policy_during_update_url end |
#stack_policy_url ⇒ Object
Returns the value of attribute stack_policy_url.
16 17 18 |
# File 'lib/stackit/stack.rb', line 16 def stack_policy_url @stack_policy_url end |
#stack_status ⇒ Object
Returns the value of attribute stack_status.
11 12 13 |
# File 'lib/stackit/stack.rb', line 11 def stack_status @stack_status end |
#stack_status_reason ⇒ Object
Returns the value of attribute stack_status_reason.
12 13 14 |
# File 'lib/stackit/stack.rb', line 12 def stack_status_reason @stack_status_reason end |
#tags ⇒ Object
Returns the value of attribute tags.
21 22 23 |
# File 'lib/stackit/stack.rb', line 21 def @tags end |
#timeout_in_minutes ⇒ Object
Returns the value of attribute timeout_in_minutes.
14 15 16 |
# File 'lib/stackit/stack.rb', line 14 def timeout_in_minutes @timeout_in_minutes end |
#use_previous_template ⇒ Object
Returns the value of attribute use_previous_template.
23 24 25 |
# File 'lib/stackit/stack.rb', line 23 def use_previous_template @use_previous_template end |
Instance Method Details
#[](key) ⇒ Object
44 45 46 |
# File 'lib/stackit/stack.rb', line 44 def [](key) parameters[key.to_sym] || outputs[key.to_sym] || resources[key.to_sym] end |
#change_set_request_params ⇒ Object
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/stackit/stack.rb', line 148 def change_set_request_params { change_set_name: change_set_name || "#{stack_name}#{Time.now.strftime("%m%d%Y%H%M%S")}", stack_name: stack_name, use_previous_template: use_previous_template, parameters: to_request_parameters, notification_arns: notification_arns, tags: } end |
#create_stack_request_params ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/stackit/stack.rb', line 114 def create_stack_request_params { stack_name: stack_name, parameters: to_request_parameters, disable_rollback: disable_rollback, timeout_in_minutes: timeout_in_minutes, notification_arns: notification_arns, on_failure: on_failure, stack_policy_body: stack_policy_body, stack_policy_url: stack_policy_url, tags: } end |
#delete_stack_request_params ⇒ Object
141 142 143 144 145 146 |
# File 'lib/stackit/stack.rb', line 141 def delete_stack_request_params { stack_name: stack_name, retain_resources: retain_resources } end |
#hydrate! ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/stackit/stack.rb', line 100 def hydrate! @stack_id = stack.stack_id @description = stack.description @creation_time = stack.creation_time @last_updated_time = stack.last_updated_time @stack_status = stack.stack_status @stack_status_reason = stack.stack_status_reason @disable_rollback = stack.disable_rollback @timeout_in_minutes = stack.timeout_in_minutes @stack_policy_body = stack.stack_policy_body if stack.respond_to?(:stack_policy_body) @stack_policy_url = stack.stack_policy_url if stack.respond_to?(:stack_policy_url) self end |
#outputs ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/stackit/stack.rb', line 58 def outputs @outputs ||= begin stack.outputs.inject({}) do |hash, output| hash.merge(output[:output_key].to_sym => output[:output_value]) end rescue ::Aws::CloudFormation::Errors::ValidationError => e [] if e. =~ /Stack with id #{stack_name} does not exist/ end end |
#resources ⇒ Object
68 69 70 71 72 |
# File 'lib/stackit/stack.rb', line 68 def resources @resources ||= list_stack_resources.inject({}) do |hash, resource| hash.merge(resource[:logical_resource_id].to_sym => resource[:physical_resource_id]) end end |
#update_stack_request_params ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/stackit/stack.rb', line 128 def update_stack_request_params { stack_name: stack_name, use_previous_template: use_previous_template, stack_policy_during_update_body: stack_policy_during_update_body, stack_policy_during_update_url: stack_policy_during_update_url, parameters: to_request_parameters, stack_policy_body: stack_policy_body, stack_policy_url: stack_policy_url, tags: } end |