Class: Ufo::CLI::Destroy

Inherits:
Base
  • Object
show all
Defined in:
lib/ufo/cli/destroy.rb

Instance Attribute Summary

Attributes inherited from Base

#task_definition

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Utils::Sure

#sure?

Methods included from Utils::Pretty

#pretty_home, #pretty_path, #pretty_time

Methods included from Utils::Logging

#logger

Methods included from Ufo::Concerns

#build, #deploy, #info, #ps

Methods included from Ufo::Concerns::Names

#names

Methods included from AwsServices

#acm, #applicationautoscaling, #aws_options, #cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #find_stack, #ssm_client, #stack_resources, #status, #task_definition_arns, #waf_client

Constructor Details

This class inherits a constructor from Ufo::CLI::Base

Instance Method Details

#are_you_sure?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ufo/cli/destroy.rb', line 27

def are_you_sure?
  sure?("You are about to destroy the #{@stack_name.color(:green)} stack")
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ufo/cli/destroy.rb', line 3

def run
  are_you_sure?

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

  if stack.stack_status =~ /_IN_PROGRESS$/
    puts "Cannot destroy service #{@service.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 stack #{@stack_name.color(:green)}"

  return unless @options[:wait]
  status.wait
end