Skip to content

Instantly share code, notes, and snippets.

@cstar
Created January 28, 2009 08:39
Show Gist options
  • Save cstar/53872 to your computer and use it in GitHub Desktop.
Save cstar/53872 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'ec2'
if ( ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY'] && ENV['EC2_PEM'])
@ec2 = EC2::Base.new(:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'], :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY'])
@ec2.describe_instances.reservationSet.item.each {|r|
r.instancesSet.item.each {|p|
system " osascript -e 'tell application \"Terminal\" to (do script with command \"ssh -i #{ENV['EC2_PEM']} root@#{p.dnsName}\")'"
}
}
else
puts "You must define EC2_PEM, AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY as shell environment variables before running #{$0}!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment