Class: CuffSert::RxCFClient
- Inherits:
-
Object
- Object
- CuffSert::RxCFClient
- Defined in:
- lib/cuffsert/rxcfclient.rb
Instance Method Summary collapse
- #abort_update(change_set_id) ⇒ Object
- #create_stack(cfargs) ⇒ Object
- #delete_stack(cfargs) ⇒ Object
- #find_stack_blocking(meta) ⇒ Object
- #get_template(meta) ⇒ Object
-
#initialize(aws_region = nil, **options) ⇒ RxCFClient
constructor
A new instance of RxCFClient.
- #prepare_update(cfargs) ⇒ Object
- #update_stack(stack_id, change_set_id) ⇒ Object
Constructor Details
#initialize(aws_region = nil, **options) ⇒ RxCFClient
Returns a new instance of RxCFClient.
9 10 11 12 13 14 15 |
# File 'lib/cuffsert/rxcfclient.rb', line 9 def initialize(aws_region = nil, **) initargs = {retry_limit: 8} initargs[:region] = aws_region if aws_region @cf = [:aws_cf] || Aws::CloudFormation::Client.new(initargs) @max_items = [:max_items] || 1000 @pause = [:pause] || 5 end |
Instance Method Details
#abort_update(change_set_id) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/cuffsert/rxcfclient.rb', line 72 def abort_update(change_set_id) Rx::Observable.create do |observer| @cf.delete_change_set(change_set_name: change_set_id) observer.on_completed end end |
#create_stack(cfargs) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cuffsert/rxcfclient.rb', line 32 def create_stack(cfargs) Rx::Observable.create do |observer| start_time = record_start_time stack_id = @cf.create_stack(cfargs)[:stack_id] stack_events(stack_id, start_time) do |event| observer.on_next(event) end observer.on_completed end end |
#delete_stack(cfargs) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cuffsert/rxcfclient.rb', line 79 def delete_stack(cfargs) eventid_cache = Set.new Rx::Observable.create do |observer| start_time = record_start_time @cf.delete_stack(cfargs) stack_events(cfargs[:stack_name], start_time) do |event| observer.on_next(event) end observer.on_completed end .select do |event| eventid_cache.add?(event[:event_id]) end end |
#find_stack_blocking(meta) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cuffsert/rxcfclient.rb', line 17 def find_stack_blocking() name = .stackname @cf.describe_stacks(stack_name: name)[:stacks][0] rescue Aws::CloudFormation::Errors::ValidationError nil end |
#get_template(meta) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/cuffsert/rxcfclient.rb', line 24 def get_template() Rx::Observable.create do |observer| template = @cf.get_template(:stack_name => .stackname) observer.on_next(YAML.load(template[:template_body])) observer.on_completed end end |
#prepare_update(cfargs) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cuffsert/rxcfclient.rb', line 43 def prepare_update(cfargs) Rx::Observable.create do |observer| change_set_id = @cf.create_change_set(cfargs)[:id] loop do change_set = @cf.describe_change_set(change_set_name: change_set_id) if FINAL_STATES.include?(change_set.data[:status]) observer.on_next(change_set.data) break end end observer.on_completed end end |
#update_stack(stack_id, change_set_id) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cuffsert/rxcfclient.rb', line 57 def update_stack(stack_id, change_set_id) Rx::Observable.create do |observer| start_time = record_start_time @cf.execute_change_set(change_set_name: change_set_id) begin stack_events(stack_id, start_time) do |event| observer.on_next(event) end rescue => e observer.on_error(e) end observer.on_completed end end |