Sha256: 5b00f85db79ee27be4cc8a10c034450ebbb0ef01d96b9567f518e6458fee4c3a

Contents?: true

Size: 1.49 KB

Versions: 19

Compression:

Stored size: 1.49 KB

Contents

class Lono::Sets
  class Delete
    include Lono::AwsServices
    include Lono::Sets::Summarize
    include Lono::Utils::Sure

    def initialize(options={})
      @options = options
      @stack = options.delete(:stack)
    end

    def run
      message = "Deleting #{@stack} stack set."
      if @options[:noop]
        puts "NOOP #{message}"
      else
        sure?("Are you sure you want to delete the #{@stack} stack set?", "Be sure that it emptied of stack instances first.")

        if stack_set_exists?(@stack)
          cfn.delete_stack_set(stack_set_name: @stack) # resp is an Empty structure, so much get operation_id from status
          puts message
        else
          puts "#{@stack.inspect} stack set does not exist".color(:red)
          return
        end
      end

      return true if @options[:noop] || !@options[:wait]

      status = Status.new(@options)
      success = status.wait
      operation_id = status.operation_id # getting operation_id from status because cfn.delete_stack_set resp is an Empty structure
      summarize(operation_id)
      exit 1 unless success

    rescue Aws::CloudFormation::Errors::StackSetNotEmptyException => e
      puts "ERROR: #{e.class}: #{e.message}".color(:red)
      puts <<~EOL
        The stack set must be empty before deleting. Cannot delete stack set until all stack instances are first
        deleted. If you want to delete all stack instances you can use:

            lono sets instances delete #{@stack} --all

      EOL
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
lono-7.4.4 lib/lono/sets/delete.rb
lono-7.4.3 lib/lono/sets/delete.rb
lono-7.4.2 lib/lono/sets/delete.rb
lono-7.4.1 lib/lono/sets/delete.rb
lono-7.4.0 lib/lono/sets/delete.rb
lono-7.3.2 lib/lono/sets/delete.rb
lono-7.3.1 lib/lono/sets/delete.rb
lono-7.3.0 lib/lono/sets/delete.rb
lono-7.2.3 lib/lono/sets/delete.rb
lono-7.2.2 lib/lono/sets/delete.rb
lono-7.2.1 lib/lono/sets/delete.rb
lono-7.2.0 lib/lono/sets/delete.rb
lono-7.1.0 lib/lono/sets/delete.rb
lono-7.0.5 lib/lono/sets/delete.rb
lono-7.0.4 lib/lono/sets/delete.rb
lono-7.0.3 lib/lono/sets/delete.rb
lono-7.0.2 lib/lono/sets/delete.rb
lono-7.0.1 lib/lono/sets/delete.rb
lono-7.0.0 lib/lono/sets/delete.rb