Sha256: 42c273acbaddc9b9722768b9d459e1234998d90a5c767782c731287b76e73624

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

require 'aws-sdk'

module AwsDump
  class Instance < Hash
    def initialize(parent, instance)
      @parent = parent
      @instance = instance
      self[:name] = instance.tags["Name"] || instance.id
      self[:public_ip] = instance.public_ip_address
      self[:private_ip] = instance.private_ip_address
      self[:instance_type] = instance.instance_type
      self[:id] = instance.id
      self[:image_id] = instance.image_id
      self[:root_device_type] = instance.root_device_type
      self[:security_groups] = security_groups
    end

    def security_groups
      list = []
      @instance.security_groups.each do |security_group|
        list << {
          :name => security_group.name,
          :id => security_group.id
        }
      end
      list
    end

    def <=>(other)
      self[:name] <=> other[:name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_dump-0.0.2 lib/aws_dump/instance.rb
aws_dump-0.0.1 lib/aws_dump/instance.rb