Skip to content

Amazon EC2

Getting Started (for Free!) with Amazon Elastic Cloud Computing (EC2)

Recently, Amazon.com announced that they were offering software developers and small businesses a full year of Amazon Elastic Cloud Computing (EC2) for free. I’ve been wanting to dig into cloud computing for some time. And, being human, I regard “free” as too good a price to pass up.

Signing up for EC2 was the easy part. Once signed up, I found myself deluged by a stream of new concepts and acronyms. In this series of articles, I’ll attempt to untangle the concepts behind EC2, and provide a step by step guide to hosting content on your new EC2 account.

How Cloud Computing Differs from Virtual Hosting

The best way to understand cloud computing is to understand how it differs from a virtual hosting account with a company such as Dreamhost or Hostgator. From a mile-high standpoint, both are providing a similar service: hosting your Web applications (HTML, PHP, .NET, Ruby on Rails, or what have you) on a server or servers maintained in a data center. Both relieve your company of the hassle of creating its own high-speed network and maintaining its own data center.

Where the two services differ dramatically is in the speed of scalability. With a virtual hosting account, you pay for tiers of performance and bandwidth. If you think your performance and network needs will be small, you can get by with a cheap virtual hosting account. If your demands exceed those needs, you’re forced to pay to rent a dedicated server. If your Web site soars in popularity, you’ll have to contract with your provider for a second dedicated server. Upgrading capacity with a virtual host can take days; meanwhile; your Web site is getting hammered, and you’re losing business due to poor performance and a lack of connections.

With cloud computing, you are renting processor time and storage in a virtually limitless execution environment. Cloud computing providers will automatically scale your available capacity to meet your demand. Unlike virtual hosting, where you pay for excess capacity regardless of whether you use it, you pay for only the execution capacity and bandwidth you actually use. Your application can start with 100 users per day, and scale seamlessly to 100,000 or 1 million.

How EC2 Works

EC2 runs your Web applications in a virtual machine instance. This instance is created using an Amazon Machine Image (AMI) configuration. You can launch as few or as many virtual servers as your application needs, scaling the number of servers up or down as its needs demand.

What makes Amazon.com’s cloud computing initiative unique is that EC2 supports a number of different operating system images. You can run Linux, Suse Enterprise Linux, Microsoft Windows Server 2008, or CentOS Cluster Server. You can also purchase access to a unique AMI from a third party vendor. For example, Zend sells an AMI of Zend Server CE, their server optimized for PHP execution.

Starting and Connecting to Your EC2 Instance

I’m assuming you’ve signed up for an account. Like I said, signing up for EC2 is the easy part. It’s the EC2 dashboard screen that takes some navigating for first-time users. The EC2 dashboard screen bombards users with an alphabet soup of techno-jargon – S3, EC2, VPC, RDS, etc. Let’s ignore the acronyms for the time being and answer the simplest question: how do I create and log in to a server?

First, you will need to create a new virtual server instance. If you log in to the EC2 screen, you’ll see a prominent button that says Launch Instance. Click it, and you will be prompted to select an operating system for your virtual server. For this article, we’re going to host a SuSE Enterprise Linux server.

[NOTE – ADDED 11/22/2010: SuSE Linux is NOT part of the free hosting plan. You will be charged instance hours for using it. You should use a micro instance of the Basic 32-bit Amazon Linux AMI instead. I will demonstrate how to use this in my next article.]

EC2 walks you through several options for configuring your virtual server. The most important for our purposes is Create Key Pair, which allows you to generate a public/private key combination for connecting to your virtual server. Generate a key and save it to your local computer; we’ll use this key in a short while to log into the server we’ve just created.

Accept the defaults for all of the other options, and you will be ready to work with your new virtual server.

Logging in to Your Virtual Server

Click on Instances on your EC2 Dashboard, and you should see your server running. The question now is: how do you log into it?

EC2 lets us establish an SS H connection from a Windows SSH client such as PuTTY. Before we can do this, however, we need to configure our server to open up connections on port 22. We’ll accomplish this by opening up port 22 on our default security group. Click Security Groups on the left hand side on the EC2 Web page, and select default. To add support for SSH, select SSH in the drop-down at the bottom of the page. Add 22 for the From Port and the To Port, and for Source (IP or group), add 0.0.0.0/0.

To log in to our instance using PuTTY, we have to use our EC2 key pair. However, Putty won’t work directly with the keys that EC2 generated for us. Fortunately, we can download PuTTYGen to convert our .pem key file into a format that PuTTY can process. Once you’ve downloaded PuTTYGen, click File->Load Private Key to load the .pem file. Then click Save Private Key to save a .ppk file that can be used by PuTTY.

In PuTTY, we can select this .ppk file in the Connection->SSH->Auth menu to use it as our private key login for our EC2 virtual server.

All we’re missing now is an address for our server! To obtain the public address for your server instance, go to the Instances page, select your running instance, and scroll down to the bottom of the page. Copy the value you find in the Public DNS field, and use this in the Host Name or IP field on PuTTY’s Terminal login screen. When prompted for a username, enter root. PuTTY will use your private key to log you in to your virtual server.

We have successfully signed up for Amazon.com EC2, created a virtual server, and logged in to our server. In our next article, we’ll start exploring the directory structure of our new server, and will discover how to host a basic HTML Web site on Apache.

Be Sociable, Share!
    The following two tabs change content below.

    11 Comments (Add Yours)

    1. Thanks, can’t wait for the next article :)

      I’d really like to try out EC2 but it looks pretty complicated.

    2. SuSE Enterprise Linux server is not free to run as a micro instance and you’ll rack up charges. Also, only the Amazon Linux AMI’s come with 10 GB of EBS, which is all that’s covered under the free tier. If you run, say, an Ubuntu Linux Server instance (which *is* covered under the free tier), it comes with 15 GB of EBS which will run you about 50 cents/month, which is hopefully close enough to free for you. But if you need totally free, at this point you either have to create your own AMI with <= 10 GB of storage or else use an Amazon Linux AMI.

    3. gr8t article! thx 4 sharing:)

    4. I’ve not actually signed in yet, but just from looking at the FAQ and website, and reading a few things, it seems it’s very easy to go beyond the “free tier” without realizing it.

      Could you more carefully explain what options are presented and what options are safe to choose to remain in the “free tier” rather then this blurb, “EC2 walks you through several options for configuring your virtual server. The most important for our purposes …” (my important for my purposes is staying with in free range)

      The two gotcha’s that I’ve seen are you are limited to 10G EBS (elastic block storage) … if you choose an image that has a “default partition” of 15 GB … you are now incurring about $0.55 a month. also you need to specify the image type , if you look at the ubuntu guide, it has –instance-type m1.large , if you do that, your looking at like over $60 bill for that month … you need to specifically make sure you are only running
      –instance-type t1.micro

      Like I said, I’ve not walked through the amazon screens myself … I don’t know if they warn you of that or carefully label things … but I wanted to be damn sure I knew which options to chose before I started poking around in it

    5. So if understand your second article right, we actually have to pay for the Enterprise instance of SuSE but not for the basic Amazon linux? Could you elaborate on this?

    6. Hi, very interesting ? How do I qualify for this : “Amazon.com announced that they were offering software developers and small businesses a full year of Amazon Elastic Cloud Computing (EC2) for free”
      I can’f find any reference to this :(.

      Who do I call/text/email/whatever to take advantage of this offering :). I really want to test the EC2, and maybe move the SVN and development server. But the prices are somewhat “prohibitive” for the purpouses I want to use this for (development), a cheap old computer is less than I would pay for 2 month of ec2.

    7. Hi all,

      Sorry, I haven’t been receiving email comments on this article for some reason, so I just saw your comments.

      Mark and Fabian – you’re correct. SuSE is NOT FREE. I’m going to update this article to reflect that. That was my bad.

      As Fabian noted, I’ve created a second article address Tom’s concern that it’s very easy to go beyond “free” without realizing it. That is, unfortunately, an Achille’s heel of using EC2 or any cloud computing service for a small-scale development project.

      Alexandru – when you go to their site, their pricing page contains details. Basically, you sign up for Micro hosting, and take extreme care not to do anything advanced or fancy. :)

    8. Thanks, I think this is enough information to get things going. With SSH, we can start doing wonders.

      • BTW. When you first try logging in with root, it will now give you an error message. So try logging in as this user id instead:
        ec2-user

        Or you can prepend this in front of your ‘DNS’ name like
        “ec2-user@ip-10-21…..”

    9. This is an absolutely awesome series of articles. It’s exactly what I was looking for: Someone to get in the water first and tell me “The water’s great! Come on in!”. For those of us who aren’t server nerds, but are still techies of some sort and could eventually figure all this out, it saves A LOT of time that would otherwise be spent drooling and staring blankly into the computer screen.

      • I should also mention that after a good 15 minutes or more of Googling “cloud computing” etc. this is the only thing I found that actually talks about moving from virtual hosting to cloud computing, instead of comparing it against maintaining your own servers on-site. That may have to do with the fact that I (embarrassingly?) never knew the term “virtual hosting”.

    Add Your Comment (Get a Gravatar)