Class: Lono::Sets::Base

Inherits:
Cfn::Base show all
Defined in:
lib/lono/sets/base.rb

Instance Method Summary collapse

Methods inherited from Cfn::Base

#capabilities, #command_with_iam, #continue_update_rollback, #continue_update_rollback_sure?, #delete_rollback_stack, #generate_all, #notification_arns, #pretty_path, #prompt_for_iam, #quit, #rerun_with_iam?, #set_template_url!, #show_options, #stack_status, #starting_message, #status, #tags

Methods included from Utils::Sure

#sure?

Methods included from AwsServices

#cfn, #ec2, #iam, #s3, #s3_presigner, #s3_resource, #sts

Methods included from AwsServices::Helper

#rollback_complete?, #testing_update?

Methods included from AwsServices::StackSet

#find_stack_set, #stack_set_exists?

Methods included from AwsServices::Stack

#find_stack, #stack_exists?

Methods inherited from AbstractBase

#reinitialize, #template_path

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



3
4
5
6
# File 'lib/lono/sets/base.rb', line 3

def initialize(options={})
  options[:iam] = true # easy to forget the --iam option. Default to turning it on for StackSets
  super
end

Instance Method Details

#build_optionsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lono/sets/base.rb', line 26

def build_options
  parameters = generate_all
  options = {
    stack_set_name: @stack,
    parameters: parameters,
    capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
  }
  options[:tags] = tags unless tags.empty?
  options[:operation_preferences] = operation_preferences unless operation_preferences.empty?
  options.reject! {|k, v| v.nil? }
  set_template_url!(options)
  options
end

#exit_unless_updatable!Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lono/sets/base.rb', line 13

def exit_unless_updatable!
  return true if ENV['LONO_ENV']
  return false if @options[:noop]

  status = Status.new(@options) # using status for completed?
  return if status.stack_instances.empty?
  completed = status.completed?(status.stack_set_status)
  unless completed
    puts "Cannot update stack set because #{@stack} is not in an updatable state.  Stack set status: #{status.stack_set_status}".color(:red)
    quit(1)
  end
end

#operation_preferencesObject



40
41
42
43
44
45
46
47
48
# File 'lib/lono/sets/base.rb', line 40

def operation_preferences
  o = {}
  o[:failure_tolerance_count] = @options[:failure_tolerance_count]
  o[:failure_tolerance_percentage] = @options[:failure_tolerance_percentage]
  o[:max_concurrent_count] = @options[:max_concurrent_count]
  o[:max_concurrent_percentage] = @options[:max_concurrent_percentage]
  o.reject! {|k, v| v.nil? }
  o
end

#runObject



8
9
10
11
# File 'lib/lono/sets/base.rb', line 8

def run
  generate_all
  save
end