0.03c/hour (14€/month) is pretty cheap for a small server so lets try this 🙂
Generate and download a key-pair, so you can login to the instance via ssh.
AMI-id used is a micro ebs ubuntu 10.04 instance on eu-west-1, choose your own at http://uec-images.ubuntu.com/releases/lucid/release
Be sure to add ssh port to your security group or you will get a nice “port 22: Connection timed out”
Start the servers!
require 'fog'
fog = Fog::Compute.new(
:provider => 'AWS',
:region=>'eu-west-1',
:aws_access_key_id => 'yyy',
:aws_secret_access_key => 'xxxx'
)
# start a server
server = fog.servers.create(
:image_id=>'ami-311f2b45',
:flavor_id=>'t1.micro',
:key_name => 'pey-pair-name'
)
# wait for it to get online
server.wait_for { print "."; ready? }
# public address -> ec2-79-125-45-252.eu- west-1.compute.amazonaws.com -> ssh into it
server.dns_name
# instance id -> find it again
fog.servers.get(server.id)
# shutdown
server.destroy
Connect via ssh
ssh -i KEY-PAIR.pem ubuntu@SERVER-DNS-NAME
Like this:
Like Loading...
Related
hi;
thanks for this. I am new to it and coming up with (Fog::Compute::AWS::NotFound). I am not clear about the key-pair. ca you help pls
create the key pair via aws console, not sure about the error, haven’t used that in a while 🙂