Class: Lono::Cfn::Download
- Inherits:
-
AbstractBase
- Object
- AbstractBase
- Lono::Cfn::Download
- Includes:
- AwsServices
- Defined in:
- lib/lono/cfn/download.rb
Instance Method Summary collapse
- #convert_to_yaml(body) ⇒ Object
- #download_path ⇒ Object
- #download_stack ⇒ Object
- #download_template ⇒ Object
- #json?(body) ⇒ Boolean
- #name ⇒ Object
- #run ⇒ Object
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
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::AbstractBase
Instance Method Details
#convert_to_yaml(body) ⇒ Object
35 36 37 |
# File 'lib/lono/cfn/download.rb', line 35 def convert_to_yaml(body) json?(body) ? YAML.dump(JSON.parse(body)) : body end |
#download_path ⇒ Object
43 44 45 |
# File 'lib/lono/cfn/download.rb', line 43 def download_path "#{Lono.config.output_path}/#{@blueprint}/templates/#{@blueprint}.yml" end |
#download_stack ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lono/cfn/download.rb', line 22 def download_stack source = @options[:source] if source open(source).read # url or file else resp = cfn.get_template( stack_name: @stack, template_stage: "Original" ) resp.template_body end end |
#download_template ⇒ Object
15 16 17 18 19 20 |
# File 'lib/lono/cfn/download.rb', line 15 def download_template body = download_stack body = convert_to_yaml(body) FileUtils.mkdir_p(File.dirname(download_path)) IO.write(download_path, body) end |
#json?(body) ⇒ Boolean
39 40 41 |
# File 'lib/lono/cfn/download.rb', line 39 def json?(body) !!JSON.parse(body) rescue false end |
#name ⇒ Object
47 48 49 |
# File 'lib/lono/cfn/download.rb', line 47 def name @options[:name] || @stack end |