Class: Stax::Aws::Asg

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

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



7
8
9
# File 'lib/stax/aws/asg.rb', line 7

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

.describe(names) ⇒ Object



11
12
13
14
15
# File 'lib/stax/aws/asg.rb', line 11

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



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

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



29
30
31
# File 'lib/stax/aws/asg.rb', line 29

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



25
26
27
# File 'lib/stax/aws/asg.rb', line 25

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