Skip to content

Instantly share code, notes, and snippets.

@pixelpogo
Last active December 14, 2015 09:19
Show Gist options
  • Select an option

  • Save pixelpogo/5064183 to your computer and use it in GitHub Desktop.

Select an option

Save pixelpogo/5064183 to your computer and use it in GitHub Desktop.

Revisions

  1. pixelpogo renamed this gist Mar 1, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. pixelpogo created this gist Mar 1, 2013.
    31 changes: 31 additions & 0 deletions list_all_aws_instances
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    require "rubygems"
    require "aws-sdk"
    require "hirb"

    extend Hirb::Console

    ec2 = AWS::EC2.new(
    :access_key_id => 'YOUR_ACCESS_KEY_ID',
    :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')

    instances = []

    ec2.regions.each do |region|
    print "\r\e[0KLooking for instances in #{region.name}..."
    $stdout.flush
    region.instances.each do |i|
    instances << {
    :id => i.id,
    :ip => i.ip_address,
    :private_ip => i.private_ip_address,
    :dns => i.dns_name,
    :status => i.status,
    :region => region.name,
    :type => i.instance_type }
    end
    end

    print "\r\e[0K"
    $stdout.flush

    table instances