Class: Lono::Cfn::Update
Instance Method Summary collapse
- #codediff_preview ⇒ Object
- #param_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_files, #build_scripts, #capabilities, #check_files, #check_for_errors, #command_with_iam, #continue_update_rollback, #continue_update_rollback_sure?, #delete_rollback_stack, #ensure_s3_bucket_exist, #exit_unless_updatable!, #generate_all, #generate_templates, #initialize, #param_generator, #post_process_templates, #pretty_path, #prompt_for_iam, #quit, #run, #set_template_body!, #show_parameters, #stack_status, #starting_message, #status, #tags, #upload_files, #upload_scripts, #upload_templates
Methods included from Util
#are_you_sure?, #switch_current
Methods included from Suffix
#allow_suffix?, #append_suffix, #random_suffix, #remove_suffix, #stack_name_suffix
Methods included from Lono::Conventions
Methods included from Blueprint::Root
#bundler_groups, #find_blueprint_root, #require_bundle_gems, #set_blueprint_root
Methods included from AwsServices
#cfn, #ec2, #iam, #s3, #s3_presigner, #s3_resource, #sts
Methods included from AwsServices::Util
#find_stack, #rollback_complete?, #stack_exists?, #testing_update?
Constructor Details
This class inherits a constructor from Lono::Cfn::Base
Instance Method Details
#codediff_preview ⇒ Object
65 66 67 |
# File 'lib/lono/cfn/update.rb', line 65 def codediff_preview Lono::Cfn::Preview::Codediff.new(@stack_name, @options.merge(mute_params: true, mute_using: true)) end |
#param_preview ⇒ Object
70 71 72 |
# File 'lib/lono/cfn/update.rb', line 70 def param_preview Lono::Cfn::Preview::Param.new(@stack_name, @options) end |
#save_stack(params) ⇒ Object
save_stack is the interface method
4 5 6 |
# File 'lib/lono/cfn/update.rb', line 4 def save_stack(params) update_stack(params) end |
#standard_update(params) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/lono/cfn/update.rb', line 47 def standard_update(params) params = { stack_name: @stack_name, parameters: params, capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"] disable_rollback: !@options[:rollback], } params[:tags] = unless .empty? set_template_body!(params) show_parameters(params, "cfn.update_stack") begin cfn.update_stack(params) rescue Aws::CloudFormation::Errors::ValidationError => e puts "ERROR: #{e.}".red false 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
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 43 44 45 |
# File 'lib/lono/cfn/update.rb', line 9 def update_stack(params) = "Updating #{@stack_name} stack" if @options[:noop] puts "NOOP #{}" return end deleted = delete_rollback_stack if deleted Create.new(@stack_name, @options).create_stack(params) 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)) = @options.merge(mute_params: true, mute_using: true, keep: true) # create new copy of preview when update_stack is called because of IAM retry logic changeset_preview = Lono::Cfn::Preview::Changeset.new(@stack_name, ) error = nil param_preview.run if @options[:param_preview] codediff_preview.run if @options[:codediff_preview] changeset_preview.run if @options[:changeset_preview] are_you_sure?(@stack_name, :update) if @options[:change_set] # defaults to this << " via change set: #{changeset_preview.change_set_name}" changeset_preview.execute_change_set else standard_update(params) end puts unless @options[:mute] || error end |