Class: Lono::Cfn::Download
- Inherits:
-
Base
- Object
- Base
- Lono::Cfn::Download
show all
- Defined in:
- lib/lono/cfn/download.rb
Instance Method Summary
collapse
Methods inherited from Base
#append_suffix, #build_scripts, #capabilities, #check_files, #check_for_errors, #command_with_iam, #convention_path, #exit_unless_updatable!, #generate_all, #generate_params, #generate_templates, #get_source_path, #initialize, #prompt_for_iam, #quit, #random_suffix, #remove_suffix, #s3_folder, #set_template_body!, #show_parameters, #stack_name_suffix, #stack_status, #starting_message, #status, #switch_current, #upload_files, #upload_scripts, #upload_templates
Methods included from Util
#are_you_sure?
Methods included from AwsService
#cfn, #stack_exists?, #testing_update?
Instance Method Details
#convert_to_yaml(body) ⇒ Object
19
20
21
|
# File 'lib/lono/cfn/download.rb', line 19
def convert_to_yaml(body)
json?(body) ? YAML.dump(JSON.parse(body)) : body
end
|
#download_path ⇒ Object
27
28
29
30
|
# File 'lib/lono/cfn/download.rb', line 27
def download_path
name = @options[:name] || @stack_name
"/tmp/#{name}.yml"
end
|
#download_template ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/lono/cfn/download.rb', line 10
def download_template
resp = cfn.get_template(
stack_name: @stack_name,
template_stage: "Original"
)
body = convert_to_yaml(resp.template_body)
IO.write(download_path, body)
end
|
#json?(body) ⇒ Boolean
23
24
25
|
# File 'lib/lono/cfn/download.rb', line 23
def json?(body)
!!JSON.parse(body) rescue false
end
|
#run ⇒ Object
4
5
6
7
8
|
# File 'lib/lono/cfn/download.rb', line 4
def run
puts "Download existing template to: #{download_path}"
return if @options[:noop]
download_template
end
|