Class: Awsm::AutoScalingGroups
- Inherits:
-
Object
- Object
- Awsm::AutoScalingGroups
- Defined in:
- lib/awsm/autoscalinggroups.rb
Instance Method Summary collapse
- #find_for(elb_name) ⇒ Object
-
#initialize ⇒ AutoScalingGroups
constructor
A new instance of AutoScalingGroups.
- #load_auto_scaling_groups ⇒ Object
Constructor Details
#initialize ⇒ AutoScalingGroups
Returns a new instance of AutoScalingGroups.
3 4 5 6 7 |
# File 'lib/awsm/autoscalinggroups.rb', line 3 def initialize @client = Aws::AutoScaling::Client.new @asg_map = {} load_auto_scaling_groups end |
Instance Method Details
#find_for(elb_name) ⇒ Object
9 10 11 |
# File 'lib/awsm/autoscalinggroups.rb', line 9 def find_for( elb_name ) @asg_map[ elb_name ] end |
#load_auto_scaling_groups ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/awsm/autoscalinggroups.rb', line 13 def load_auto_scaling_groups @client.describe_auto_scaling_groups.each_page do |p| p.auto_scaling_groups.map do |asg| asg.load_balancer_names.each do |elb_name| @asg_map[elb_name] = [] if @asg_map[elb_name].nil? @asg_map[elb_name] << { asg_name: asg.auto_scaling_group_name, instances: asg.instances.map{ |i| i.to_h }, instance_ids: asg.instances.map { |i| i.instance_id } } end end end end |