Sha256: 41b81baa4e55443b7412de4823dd6a032ee57b61fcfff303dab05e1f8c2c2f04

Contents?: true

Size: 1.23 KB

Versions: 20

Compression:

Stored size: 1.23 KB

Contents

module Ufo::S3
  class Rollback
    extend Memoist
    include Ufo::AwsServices
    include Ufo::Utils::Logging

    def initialize(stack)
      @stack = stack
    end

    def delete_stack
      return unless complete?
      logger.info "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
      cfn.delete_stack(stack_name: @stack)
      status.wait
      status.reset
      true
    end

    def continue_update
      continue_update?
      begin
        cfn.continue_update_rollback(stack_name: @stack)
      rescue Aws::CloudFormation::Errors::ValidationError => e
        logger.info "ERROR: Continue update: #{e.message}".color(:red)
        quit 1
      end
    end

    def continue_update?
      logger.info <<~EOL
        The stack is in the UPDATE_ROLLBACK_FAILED state. More info here: https://amzn.to/2IiEjc5
        Would you like to try to continue the update rollback? (y/N)
      EOL

      yes = @options[:yes] ? "y" : $stdin.gets
      unless yes =~ /^y/
        logger.info "Exiting without continuing the update rollback."
        quit 0
      end
    end

    def complete?
      stack&.stack_status == 'ROLLBACK_COMPLETE'
    end

    def stack
      find_stack(@stack)
    end
    memoize :stack
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ufo-6.3.13 lib/ufo/s3/rollback.rb
ufo-6.3.12 lib/ufo/s3/rollback.rb
ufo-6.3.11 lib/ufo/s3/rollback.rb
ufo-6.3.10 lib/ufo/s3/rollback.rb
ufo-6.3.9 lib/ufo/s3/rollback.rb
ufo-6.3.8 lib/ufo/s3/rollback.rb
ufo-6.3.7 lib/ufo/s3/rollback.rb
ufo-6.3.6 lib/ufo/s3/rollback.rb
ufo-6.3.5 lib/ufo/s3/rollback.rb
ufo-6.3.4 lib/ufo/s3/rollback.rb
ufo-6.3.3 lib/ufo/s3/rollback.rb
ufo-6.3.2 lib/ufo/s3/rollback.rb
ufo-6.3.1 lib/ufo/s3/rollback.rb
ufo-6.3.0 lib/ufo/s3/rollback.rb
ufo-6.2.5 lib/ufo/s3/rollback.rb
ufo-6.2.4 lib/ufo/s3/rollback.rb
ufo-6.2.3 lib/ufo/s3/rollback.rb
ufo-6.2.2 lib/ufo/s3/rollback.rb
ufo-6.2.1 lib/ufo/s3/rollback.rb
ufo-6.2.0 lib/ufo/s3/rollback.rb