Class: CuffSert::CreateStackAction

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



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cuffsert/actions.rb', line 59

def as_observable
  cfargs = CuffSert.as_create_stack_args(@meta)
  upload_uri, maybe_upload = upload_template_if_oversized(cfargs)
  cfargs[:template_url] = upload_uri if upload_uri
  maybe_upload.concat(
    Rx::Observable.of([:create, @meta.stackname]),
    Rx::Observable.defer do
      if @confirmation.call(@meta, :create, nil)
        Rx::Observable.concat(
          @cfclient.create_stack(cfargs),
          Done.new.as_observable
        )
      else
        Abort.new('User abort!').as_observable
      end
    end
  )
end

#validate!Object



53
54
55
56
57
# File 'lib/cuffsert/actions.rb', line 53

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