Sha256: 031a437ddd746106cbe228ac8be78a7afd493508e8422353791c330681eb280a
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
require 'highline/import' module AwsAuditor class Stack extend OpsWorksWrapper extend EC2Wrapper attr_accessor :id, :name, :instances def initialize(aws_stack) @id = aws_stack[:stack_id] @name = aws_stack[:name] @instances = get_instances.compact end def get_instances instances = self.class.opsworks.describe_instances({stack_id: id})[:instances] instances.map do |instance| next unless instance[:status].to_s == 'online' self.class.all_instances[instance[:ec2_instance_id]] end end def print_instances EC2Instance.instance_count_hash(self.instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end end def pretty_print puts "----------------------------------" puts "#{@name}" puts "----------------------------------" print_instances puts "\n" end def self.all stacks = opsworks.describe_stacks stacks.data[:stacks].map do |stack| new(stack) end.sort! { |a,b| a.name.downcase <=> b.name.downcase } if stacks end def self.all_instances @all_instances ||= EC2Instance.instance_hash end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aws_auditor-0.1.2 | lib/aws_auditor/stack.rb |
aws_auditor-0.1.1 | lib/aws_auditor/stack.rb |
aws_auditor-0.1.0 | lib/aws_auditor/stack.rb |