Class: Stax::Aws::Asg

Inherits:
Sdk
  • Object
show all
Defined in:
lib/stax/aws/asg.rb

Constant Summary

Constants inherited from Sdk

Sdk::RETRY_LIMIT

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



9
10
11
# File 'lib/stax/aws/asg.rb', line 9

def client
  @_client ||= ::Aws::AutoScaling::Client.new
end

.describe(names) ⇒ Object



13
14
15
16
17
# File 'lib/stax/aws/asg.rb', line 13

def describe(names)
  paginate(:auto_scaling_groups) do |token|
    client.describe_auto_scaling_groups(auto_scaling_group_names: Array(names), next_token: token)
  end
end

.instances(names) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/stax/aws/asg.rb', line 19

def instances(names)
  ids = describe(names).map(&:instances).flatten.map(&:instance_id)
  return [] if ids.empty? # below call will return all instances in a/c if this empty
  paginate(:auto_scaling_instances) do |token|
    client.describe_auto_scaling_instances(instance_ids: ids, next_token: token)
  end
end

.terminate(id, decrement = false) ⇒ Object



31
32
33
# File 'lib/stax/aws/asg.rb', line 31

def terminate(id, decrement = false)
  client.terminate_instance_in_auto_scaling_group(instance_id: id, should_decrement_desired_capacity: decrement)
end

.update(name, opt = {}) ⇒ Object



27
28
29
# File 'lib/stax/aws/asg.rb', line 27

def update(name, opt = {})
  client.update_auto_scaling_group(opt.merge(auto_scaling_group_name: name))
end