Sha256: 1dd0193d8acb12b52d0e3a39b40097bb0d1d75428b592ae26b4efc52d1a1653c

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module Ufo
  class Destroy < Base
    def bye
      unless are_you_sure?
        puts "Phew, that was close"
        return
      end

      stack = find_stack(@stack_name)
      unless stack
        puts "Stack #{@stack_name.color(:green)} does not exist."
        exit
      end

      if stack.stack_status =~ /_IN_PROGRESS$/
        puts "Cannot destroy service #{@pretty_service_name.color(:green)}"
        puts "Cannot delete stack #{@stack_name.color(:green)} in this state: #{stack.stack_status.color(:green)}"
        puts "If the stack is taking a long time, you can cancel the current operation with:"
        puts "  ufo cancel #{@service}"
        return
      end

      cloudformation.delete_stack(stack_name: @stack_name)
      puts "Deleting CloudFormation stack with ECS resources: #{@stack_name}."

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

    def are_you_sure?
      return true if @options[:sure]
      puts "You are about to destroy #{@pretty_service_name.color(:green)} service on the #{@cluster.color(:green)} cluster."
      print "Are you sure you want to do this? (y/n) "
      answer = $stdin.gets.strip
      answer =~ /^y/
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ufo-4.3.1 lib/ufo/destroy.rb
ufo-4.3.0 lib/ufo/destroy.rb
ufo-4.2.0 lib/ufo/destroy.rb