Class: Lono::Cfn::Preview::Param

Inherits:
Base
  • Object
show all
Includes:
AwsServices, DiffViewer
Defined in:
lib/lono/cfn/preview/param.rb

Instance Method Summary collapse

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?

Methods included from DiffViewer

#diff_viewer, #show_diff

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, #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

#template_param_convention

Methods included from Blueprint::Root

#bundler_groups, #find_blueprint_root, #require_bundle_gems, #set_blueprint_root

Constructor Details

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

Instance Method Details

#existing_parametersObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lono/cfn/preview/param.rb', line 25

def existing_parameters
  resp = cfn.describe_stacks(stack_name: @stack_name)
  stack = resp.stacks.first
  parameters = stack.parameters

  # Remove optional parameters if they match already. Produces better diff.
  optional = optional_parameters.map do |logical_id, attributes|
    {
      "ParameterKey" => logical_id,
      "ParameterValue" => attributes["Default"],
    }
  end
  converted = convert_to_cfn_format(parameters)
  converted - optional
end

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lono/cfn/preview/param.rb', line 9

def run
  return unless stack_exists?(@stack_name)

  puts "Parameter Diff Preview:".color(:green)
  if @options[:noop]
    puts "NOOP CloudFormation parameters preview for #{@stack_name} update"
    return
  end

  params = generate_all
  write_to_tmp(new_path, params)
  write_to_tmp(existing_path, existing_parameters)

  show_diff(existing_path, new_path)
end