Sha256: 53c44253ff9f1128c14889faffaaf90294e44426b6442f8f8810192eaf22cf55

Contents?: true

Size: 917 Bytes

Versions: 5

Compression:

Stored size: 917 Bytes

Contents

class Lono::Cfn::Delete
  include Lono::Cfn::AwsService
  include Lono::Cfn::Util

  def initialize(stack_name, options={})
    @stack_name = switch_current(stack_name)
    @options = options
  end

  def run
    message = "Deleted #{@stack_name} stack."
    if @options[:noop]
      puts "NOOP #{message}"
    else
      are_you_sure?(@stack_name, :delete)

      if stack_exists?(@stack_name)
        cfn.delete_stack(stack_name: @stack_name)
        puts message
      else
        puts "#{@stack_name.inspect} stack does not exist".colorize(:red)
      end
    end

    return unless @options[:wait]
    start_time = Time.now
    status.wait
    took = Time.now - start_time
    puts "Time took for stack deletion: #{status.pretty_time(took).green}."
  end

  def status
    @status ||= Lono::Cfn::Status.new(@stack_name)
  end

  def switch_current(stack_name)
    Lono::Cfn::Current.name!(stack_name)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lono-4.2.4 lib/lono/cfn/delete.rb
lono-4.2.3 lib/lono/cfn/delete.rb
lono-4.2.2 lib/lono/cfn/delete.rb
lono-4.2.1 lib/lono/cfn/delete.rb
lono-4.2.0 lib/lono/cfn/delete.rb