Sha256: be01503264ba134ea6275b93ce2faa74ae6accadafb23a881f8344e64c91e49c

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require "yaml"

class Lono::Cfn::Create < Lono::Cfn::Base
  # save_stack is the interface method
  def save_stack(params)
    create_stack(params)
  end

  # aws cloudformation create-stack --stack-name prod-hi-123456789 --parameters file://output/params/prod-hi-123456789.json --template-body file://output/prod-hi.json
  def create_stack(params)
    message = "Creating #{@stack_name.color(:green)} stack."
    if @options[:noop]
      puts "NOOP #{message}"
      return
    end

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

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

    params = {
      stack_name: @stack_name,
      parameters: params,
      capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
      disable_rollback: !@options[:rollback],
      tags: tags,
    }
    set_template_body!(params)

    show_parameters(params, "cfn.create_stack")
    cfn.create_stack(params)
    puts message unless @options[:mute]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lono-4.2.7 lib/lono/cfn/create.rb
lono-4.2.6 lib/lono/cfn/create.rb