Class: Moonshot::StackASGPrinter

Inherits:
Object
  • Object
show all
Includes:
CredsHelper
Defined in:
lib/moonshot/stack_asg_printer.rb

Overview

Display information about the AutoScaling Groups, associated ELBs, and managed instances to the user.

Instance Method Summary collapse

Methods included from CredsHelper

#as_client, #cd_client, #cf_client, #ec2_client, #iam_client, #s3_client

Constructor Details

#initialize(stack, table) ⇒ StackASGPrinter

Returns a new instance of StackASGPrinter.



11
12
13
14
# File 'lib/moonshot/stack_asg_printer.rb', line 11

def initialize(stack, table)
  @stack = stack
  @table = table
end

Instance Method Details



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/moonshot/stack_asg_printer.rb', line 16

def print
  asgs.each do |asg|
    asg_info = as_client.describe_auto_scaling_groups(
      auto_scaling_group_names: [asg.physical_resource_id])
                        .auto_scaling_groups.first
    t_asg_info = @table.add_leaf("ASG: #{asg.logical_resource_id}")

    add_asg_info(t_asg_info, asg_info)
    instances_leaf = t_asg_info.add_leaf('Instances')

    if asg_info.instances.empty?
      instances_leaf.add_line('There are no instances in this Auto-Scaling Group.')
    else
      instances_leaf.add_table(create_instance_table(asg_info))
    end

    add_recent_activity_leaf(t_asg_info, asg.physical_resource_id)
  end
end