savagegus
6/13/2012 - 5:53 PM

Using of to spin up a tiny proxy server in AWS.

Using of to spin up a tiny proxy server in AWS.

#!/usr/bin/env ruby

require 'rubygems'
require 'fog'

ACCESS_KEY_ID='XXX'
SECRET_ACCESS_KEY='XXX'

ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)

autoproxy_options = { 
  :image_id => 'ami-a6f504cf',
  :key_name => 'gsg-keypair',
  :availability_zone => 'us-east-1b'
}

server = ec2.servers.create(:image_id => "ami-a6f504cf", :keyname => "gsg-keypair")

until server.state == "running"
  puts server.state
end

puts server.dns_name

server.destroy