Tuesday, May 06, 2008

Amazon EC2 - My First Step into the Cloud

Ever since returning from the Web 2.0 Expo in San Francisco last month, I have been excited about learning how to setup a machine in the Amazon Elastic Compute Cloud (EC2). My first goal was just to get a Linux machine running in the cloud on which later I will try to install enough software to get a basic web application running.

To learn what to do, I consulted a the Programming Amazon Web Services book which is fortunately available on Safari Online. In parallel I read the Getting Started Guide on Amazon's website. The steps to get a virtual machine running were roughly the following:
  • Register for Amazon EC2.
  • Download a X.509 certificate private key and public key pair and store them in a ~/.ec2 directory on my computer.
  • Take note of my AWS account number.
  • Download the Amazon EC2 Command-Line Tools
  • Set environment variables: EC2_HOME, EC2_PRIVATE_KEY, EC2_CERT
  • Run ec2-describe-images -o self -o amazon to search for images.
  • Generate keypair using ec2-add-keypair gsg-keypair
  • Fired up the Getting Started AMI with ec2-run-instances ami-2bb65342 -k gsg-keypair
  • Open SSH and HTTP ports: ec2-authorize default -p 22, ec2-authorize default -p 80
  • SSH into the instance: ssh -i id_rsa_gsg_keypair root@ec2-75-101-209-13.compute-1.amazonaws.com
  • Access the instance's web server: http://ec2-75-101-209-13.compute-1.amazonaws.com/
  • Shutdown the instance: ec2-terminate-instances i-db6ea2b2
That's it! Everything worked as advertised and I got through all of that in less than an hour. This whole procedure cost me about 10 cents. I am looking forward to my next goal which is to find an Ubuntu server image, install a database with data, and learn how to preserve the data so that it survives an image restart.


Anonymous said...

As far as Ubuntu AMIs go, you are welcome to use one of the ones listed here: http://alestic.com

I would recommend starting with the Hardy or Gutsy base install.

We also have a group for Ubuntu on EC2 here: http://groups.google.com/group/ec2ubuntu

As for preserving data, you might want to search the EC2 forum as this is an important, complex, and hotly debated topic: http://ec2forum.notlong.com

--Eric Hammond

Mitchell Blankenship said...

There is a pretty cool place to not only build an image but also have it deployed to your cloud with a web based management interface.