Class: Lono::Cfn::Create

Inherits:
Base show all
Defined in:
lib/lono/cfn/create.rb

Instance Method Summary collapse

Methods inherited from Base

#capabilities, #command_with_iam, #continue_update_rollback, #continue_update_rollback_sure?, #delete_rollback_stack, #exit_unless_updatable!, #generate_all, #notification_arns, #pretty_path, #prompt_for_iam, #quit, #rerun_with_iam?, #run, #set_template_url!, #show_options, #stack_status, #starting_message, #status, #tags

Methods included from Utils::Sure

#sure?

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

#find_stack, #stack_exists?

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

#save(parameters) ⇒ Object

save is the interface method aws cloudformation create-stack –stack-name prod-hi-123456789 –parameters file://output/params/prod-hi-123456789.json –template-body file://output/prod-hi.json



7
8
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
# File 'lib/lono/cfn/create.rb', line 7

def save(parameters)
  message = "Creating #{@stack.color(:green)} stack."
  if @options[:noop]
    puts "NOOP #{message}"
    return
  end

  delete_rollback_stack

  if stack_exists?(@stack)
    puts "Cannot create #{@stack.color(:green)} stack because it already exists.".color(:red)
    return
  end

  unless File.exist?(template_path)
    puts "Cannot create #{@stack.color(:green)} template not found: #{template_path}."
    return
  end

  options = {
    capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
    disable_rollback: !@options[:rollback],
    parameters: parameters,
    stack_name: @stack,
  }
  options[:notification_arns] = notification_arns if notification_arns
  options[:tags] = tags unless tags.empty?
  set_template_url!(options)

  show_options(options, "cfn.create_stack")
  cfn.create_stack(options) # TODO: COMMENT OUT FOR TESTING
  puts message unless @options[:mute]
end