Created
December 19, 2010 23:57
-
-
Save mndoci/747850 to your computer and use it in GitHub Desktop.
Simple script uses fog to provision an EC2 instance
This file contains hidden or 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 'fog' | |
| # Credentials in ./config.rb | |
| require "./config.rb" | |
| # Set up a connection | |
| connection = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => @aws_access_key_id, | |
| :aws_secret_access_key => @aws_secret_access_key) | |
| server = connection.servers.create(:image_id => @ami_id, | |
| :flavor_id => @default_instance_type, | |
| :key_name => @key_name, | |
| :availability_zone => @availability_zone) | |
| # wait for it to be ready to do stuff | |
| server.wait_for { print "."; ready? } | |
| puts "Public IP Address: #{server.public_ip_address}" | |
| puts "Private IP Address: #{server.private_ip_address}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment