Class: CuffSert::RecreateStackAction

Inherits:
BaseAction show all
Defined in:
lib/cuffsert/actions.rb

Instance Attribute Summary

Attributes inherited from BaseAction

#cfclient, #confirmation, #s3client

Instance Method Summary collapse

Methods inherited from BaseAction

#initialize, #upload_template_if_oversized

Constructor Details

This class inherits a constructor from CuffSert::BaseAction

Instance Method Details

#as_observableObject



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/cuffsert/actions.rb', line 159

def as_observable
  crt_args = CuffSert.as_create_stack_args(@meta)
  del_args = CuffSert.as_delete_stack_args(@stack)
  upload_uri, maybe_upload = upload_template_if_oversized(crt_args)
  crt_args[:template_url] = upload_uri if upload_uri
  maybe_upload.concat(
    Rx::Observable.of([:recreate, @stack]),
    Rx::Observable.defer do
      if @confirmation.call(@meta, :recreate, @stack)
        Rx::Observable.concat(
          @cfclient.delete_stack(del_args),
          @cfclient.create_stack(crt_args),
          Done.new.as_observable
        )
      else
        CuffSert::Abort.new('User abort!').as_observable
      end
    end
  )
end

#validate!Object



153
154
155
156
157
# File 'lib/cuffsert/actions.rb', line 153

def validate!
  if @meta.stack_uri.nil?
    raise "You need to pass a template to re-create #{@meta.stackname}" # in #{@meta.aws_region}."
  end
end