Class: Lono::Cfn::Create
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create_stack(params) ⇒ Object
aws cloudformation create-stack –stack-name prod-hi-123456789 –parameters file://output/params/prod-hi-123456789.json –template-body file://output/prod-hi.json.
-
#randomize(stack_name) ⇒ Object
Appends a short random string at the end of a stack name.
-
#save_stack(params) ⇒ Object
save_stack is the interface method.
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_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
#create_stack(params) ⇒ Object
aws cloudformation create-stack –stack-name prod-hi-123456789 –parameters file://output/params/prod-hi-123456789.json –template-body file://output/prod-hi.json
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 |
# File 'lib/lono/cfn/create.rb', line 10 def create_stack(params) = "Creating #{@stack_name} stack." if @options[:noop] puts "NOOP #{}" return end if stack_exists?(@stack_name) puts "Cannot create '#{@stack_name}' stack because it already exists.".colorize(:red) return end unless File.exist?(@template_path) puts "Cannot create '#{@stack_name}' template not found: #{@template_path}." return end 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.create_stack") cfn.create_stack(params) puts unless @options[:mute] end |
#randomize(stack_name) ⇒ Object
Appends a short random string at the end of a stack name. Later we will strip this same random string from the template name. Very makes it convenient. We can just type:
lono cfn create main --randomize-stack-name
instead of:
lono cfn create main-[RANDOM] --template main
The randomize_stack_name can be specified at the CLI but can also be saved as a preference.
It is not a default setting because it might confuse new lono users.
54 55 56 57 58 59 60 61 |
# File 'lib/lono/cfn/create.rb', line 54 def randomize(stack_name) if randomize_stack_name? random = (0...3).map { (65 + rand(26)).chr }.join.downcase # Ex: jhx [stack_name, random].join('-') else stack_name end end |
#save_stack(params) ⇒ Object
save_stack is the interface method
5 6 7 |
# File 'lib/lono/cfn/create.rb', line 5 def save_stack(params) create_stack(params) end |