Created
January 28, 2009 08:39
-
-
Save cstar/53872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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