require_relative './instance_helper' module AwsAuditor class EC2Instance extend InstanceHelper extend EC2Wrapper class < [{:name => "resource-id", :values => [instance.id]}])[:tag_set] tags = Hash[tags.map { |tag| [tag[:key], tag[:value]]}.compact] instance.name = tags["Name"] instance.stack_name = tags["opsworks:stack"] end end private_class_method :get_more_info def self.bucketize buckets = {} get_instances.map do |instance| name = instance.stack_name || instance.name if name buckets[name] = [] unless buckets.has_key? name buckets[name] << instance else puts "Could not sort #{instance.id}, as it has no stack_name or name" end end buckets.sort_by{|k,v| k } end end end