Class: Lono::Sets::Delete

Inherits:
Object
  • Object
show all
Includes:
AwsServices, Summarize, Utils::Sure
Defined in:
lib/lono/sets/delete.rb

Instance Method Summary collapse

Methods included from Utils::Sure

#sure?

Methods included from Summarize

#summarize

Methods included from AwsServices

#cfn, #ec2, #iam, #s3, #s3_presigner, #s3_resource, #sts

Methods included from AwsServices::Helper

#rollback_complete?, #testing_update?

Methods included from AwsServices::StackSet

#find_stack_set, #stack_set_exists?

Methods included from AwsServices::Stack

#find_stack, #stack_exists?

Constructor Details

#initialize(options = {}) ⇒ Delete

Returns a new instance of Delete.



7
8
9
10
# File 'lib/lono/sets/delete.rb', line 7

def initialize(options={})
  @options = options
  @stack = options[:stack]
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lono/sets/delete.rb', line 12

def run
  message = "Deleting #{@stack} stack set."
  if @options[:noop]
    puts "NOOP #{message}"
  else
    desc ="      Be sure that the emptied StackSet instances is emptied first.\n      You can empty it with a separate command: lono set_instances delete \#{@stack} --all\n      This command will only delete the StackSet itself after its been emptied.\n    EOL\n    sure?(\"Are you sure you want to delete the \#{@stack} stack set?\", desc)\n\n    if stack_set_exists?(@stack)\n      cfn.delete_stack_set(stack_set_name: @stack) # resp is an Empty structure, so must get operation_id from status\n      puts message\n    else\n      puts \"\#{@stack.inspect} stack set does not exist\".color(:red)\n      return\n    end\n  end\nrescue Aws::CloudFormation::Errors::StackSetNotEmptyException => e\n  puts \"ERROR: \#{e.class}: \#{e.message}\".color(:red)\n  puts <<~EOL\n    The stack set must be empty before deleting. Cannot delete stack set until all stack instances are first\n    deleted. If you want to delete all stack instances you can use:\n\n        lono set_instances delete \#{@stack} --all\n\n  EOL\nend\n"