Class: Lono::Cfn::Update
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #change_set_update ⇒ Object
- #diff ⇒ Object
- #preview ⇒ Object
-
#save_stack(params) ⇒ Object
save_stack is the interface method.
- #standard_update(params) ⇒ Object
-
#update_stack(params) ⇒ Object
aws cloudformation update-stack –stack-name prod-hi-123456789 –parameters file://output/params/prod-hi-123456789.json –template-body file://output/prod-hi.json.
Methods inherited from Base
#build_scripts, #capabilities, #check_files, #check_for_errors, #command_with_iam, #convention_path, #derandomize, #exit_unless_updatable!, #generate_all, #generate_params, #generate_templates, #get_source_path, #initialize, #prompt_for_iam, #quit, #randomize, #randomize_stack_name?, #run, #s3_folder, #show_parameters, #stack_status, #upload_scripts, #upload_templates
Methods included from Util
Methods included from AwsService
#cfn, #stack_exists?, #testing_update?
Constructor Details
This class inherits a constructor from Lono::Cfn::Base
Instance Method Details
#change_set_update ⇒ Object
62 63 64 |
# File 'lib/lono/cfn/update.rb', line 62 def change_set_update preview.execute_change_set end |
#diff ⇒ Object
58 59 60 |
# File 'lib/lono/cfn/update.rb', line 58 def diff @diff ||= Lono::Cfn::Diff.new(@stack_name, @options.merge(lono: false, mute_params: true, mute_using: true)) end |
#preview ⇒ Object
53 54 55 56 |
# File 'lib/lono/cfn/update.rb', line 53 def preview = @options.merge(lono: false, mute_params: true, mute_using: true, keep: true) @preview ||= Lono::Cfn::Preview.new(@stack_name, ) end |
#save_stack(params) ⇒ Object
save_stack is the interface method
3 4 5 |
# File 'lib/lono/cfn/update.rb', line 3 def save_stack(params) update_stack(params) end |
#standard_update(params) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lono/cfn/update.rb', line 35 def standard_update(params) template_body = IO.read(@template_path) params = { stack_name: @stack_name, template_body: template_body, parameters: params, capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"] disable_rollback: !@options[:rollback], } show_parameters(params, "cfn.update_stack") begin cfn.update_stack(params) rescue Aws::CloudFormation::Errors::ValidationError => e puts "ERROR: #{e.}".red error = true end end |
#update_stack(params) ⇒ Object
aws cloudformation update-stack –stack-name prod-hi-123456789 –parameters file://output/params/prod-hi-123456789.json –template-body file://output/prod-hi.json
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 |
# File 'lib/lono/cfn/update.rb', line 8 def update_stack(params) = "Updating #{@stack_name} stack" if @options[:noop] puts "NOOP #{}" return end unless stack_exists?(@stack_name) puts "Cannot update a stack because the #{@stack_name} does not exists." return end exit_unless_updatable!(stack_status(@stack_name)) error = nil diff.run if @options[:diff] preview.run if @options[:preview] are_you_sure?(@stack_name, :update) if @options[:change_set] # defaults to this << " via change set: #{preview.change_set_name}" change_set_update else standard_update(params) end puts unless @options[:mute] || error end |