class Stackit::Stack
Attributes
capabilities[RW]
change_set_name[RW]
cloudformation[RW]
creation_time[RW]
description[RW]
disable_rollback[RW]
last_updated_time[RW]
notification_arns[RW]
on_failure[RW]
parameters[RW]
retain_resources[RW]
stack_id[RW]
stack_name[RW]
stack_policy_body[RW]
stack_policy_during_update_body[RW]
stack_policy_during_update_url[RW]
stack_policy_url[RW]
stack_status[RW]
stack_status_reason[RW]
timeout_in_minutes[RW]
use_previous_template[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/stackit/stack.rb, line 27 def initialize(options = {}) options = options.to_h.symbolize_keys! self.cloudformation = options[:cloudformation] || Stackit.cloudformation self.stack_name = options[:stack_name] self.description = options[:description] self.parameters = options[:parameters] self.disable_rollback = options[:disable_rollback] self.notification_arns = options[:notification_arns] self.timeout_in_minutes = options[:timeout_in_minutes] self.capabilities = options[:capabilities] self.tags = options[:tags] self.on_failure = options[:on_failure] self.use_previous_template = options[:use_previous_template] self.retain_resources = options[:retain_resources] self.change_set_name = options[:change_set_name] end
Public Instance Methods
[](key)
click to toggle source
# 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()
click to toggle source
# 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: to_request_tags } end
create_stack_request_params()
click to toggle source
# 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: to_request_tags } end
delete_stack_request_params()
click to toggle source
# File lib/stackit/stack.rb, line 141 def delete_stack_request_params { stack_name: stack_name, retain_resources: retain_resources } end
hydrate!()
click to toggle source
# 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()
click to toggle source
# 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.message =~ /Stack with id #{stack_name} does not exist/ end end
resources()
click to toggle source
# 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()
click to toggle source
# 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: to_request_tags } end
Private Instance Methods
list_stack_resources(next_token = nil)
click to toggle source
# File lib/stackit/stack.rb, line 167 def list_stack_resources(next_token = nil) result = [] response = cloudformation.list_stack_resources( stack_name: stack.stack_id ).inject([]) do |arr, page| arr.concat(page[:stack_resource_summaries]) end end
stack()
click to toggle source
# File lib/stackit/stack.rb, line 161 def stack @stack ||= cloudformation.describe_stacks( stack_name: stack_name )[:stacks].first end
to_request_parameters(params = parameters)
click to toggle source
# File lib/stackit/stack.rb, line 176 def to_request_parameters(params = parameters) params.map do |k, v| if v == :use_previous_value || v == 'use_previous_value' { 'parameter_key' => k, 'use_previous_value' => true } else { 'parameter_key' => k, 'parameter_value' => v || '' } end end end