Class: Lono::Sets::Update

Inherits:
Base show all
Includes:
Summarize
Defined in:
lib/lono/sets/update.rb

Instance Method Summary collapse

Methods included from Summarize

#summarize

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 Base

#build_options, #exit_unless_updatable!, #initialize, #operation_preferences, #run

Methods inherited from Cfn::Base

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

Methods included from Utils::Sure

#sure?

Methods inherited from AbstractBase

#initialize, #reinitialize, #template_path

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

This class inherits a constructor from Lono::Sets::Base

Instance Method Details

#codediff_previewObject



64
65
66
# File 'lib/lono/sets/update.rb', line 64

def codediff_preview
  Lono::Sets::Preview::Codediff.new(@options.merge(mute_params: true, mute_using: true))
end

#long_descObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/lono/sets/update.rb', line 49

def long_desc
  info = stack_instances.inject({}) do |result, instance|
    result[instance.] ||= []
    result[instance.] << instance.region
    result
  end
  message = "Will deploy to:\n"
  info.each do |, regions|
    message << "  account: #{}\n"
    message << "  regions: #{regions.join(",")}\n"
  end
  message << "\nNumber of stack instances to be updated: #{stack_instances.size}"
  message
end

#param_previewObject



69
70
71
# File 'lib/lono/sets/update.rb', line 69

def param_preview
  Lono::Sets::Preview::Param.new(@options)
end

#saveObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/lono/sets/update.rb', line 5

def save
  message = "Updating #{@stack} stack set"
  if @options[:noop]
    puts "NOOP #{message}"
    return
  end

  unless stack_set_exists?(@stack)
    puts "ERROR: Cannot update a stack set because #{@stack} does not exists.".color(:red)
    return
  end
  exit_unless_updatable!

  param_preview.run if @options[:param_preview]
  codediff_preview.run if @options[:codediff_preview]
  # changeset preview not supported for stack sets

  options = build_options
  show_options(options, "cfn.update_stack_set")

  if stack_instances.empty?
    puts <<~EOL
      NOTE: There are 0 stack instances associated with the #{@stack} stack set.
      Will update the stack set template but there no instances to be updated.

      Use `lono set_instances deploy` to add stack instances. Example:

          lono set_instances deploy #{@stack} --accounts 111 --regions us-west-2 us-east-2

    EOL
  else
    sure?("Are you sure you want to update the #{@stack} stack set?", long_desc)
  end

  resp = cfn.update_stack_set(options)

  Lono::Sets::Waiter.new(@options).run(resp[:operation_id])
end

#stack_instancesObject



44
45
46
# File 'lib/lono/sets/update.rb', line 44

def stack_instances
  Lono::Sets::Status::Instances.new(@options).stack_instances
end