Sha256: ec9b7bde08077b98afb404856dba85d7446404376eb51146aaffb3999c81d643

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

class Lono::Cfn::Delete
  include Lono::AwsServices
  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".color(:red)
      end
    end

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-5.1.1 lib/lono/cfn/delete.rb
lono-5.1.0 lib/lono/cfn/delete.rb
lono-5.0.1 lib/lono/cfn/delete.rb