Saturday, October 20, 2012

Getting Your Feet Wet with AWS - Part 1: Create Amazon EC2 Instance

Although this tutorial was written with an absolute beginner in mind, some general computer knowledge is required in order to complete it.

On a very basic level, AWS (Amazon Web Services) is fairly easy to use. However, if you are totally new to virtualization, at first, it may be somewhat confusing primarily because the documentation, although quite extensive, is, for the most part, not written for the "uninitiated".

Luckily, Amazon offers one year of AWS for free. The free offer includes: one micro instance of Amazon EC2 (Amazon Elastic Compute Cloud) and one micro instance of Amazon RDS (Amazon Relational Database Service). As the word "micro" implies, these are not computing powerhouses, but they are enough for anyone, even without advanced computer knowledge, to "poke around" and figure out the basics of how they work and how to manage them.

Creating an account (the one that you use to buy books and... stuff) is pretty straightforward (besides, there are hardly many people left who still do not have one), so I will skip that part. Actually, I don't even know whether you need a regular account in order to sign up for an AWS account (most likely, you don't, but I may be wrong). So, head over to the AWS web site, click the big yellow button "Sign Up Now", follow the prompts to create an AWS account, and then come back here for further instructions.

Now that you have an AWS account, go to the AWS home page. Navigate to AWS Management Console by selecting it from the "My Account / Console" drop-down list in the upper right-hand corner (if you have not signed in, you will be prompted to do so). Then, click "EC2" in order to get to EC2 Management Console. Of course, you can go to EC2 Management Console directly (again, of you have not signed in, you will be prompted to do so).

    For our first Amazon EC2 instance we will be using Amazon Linux AMI ("AMI" stands for "Amazon Machine Image"; "Amazon Linux" is Amazon's own REHL/CentOS/Fedora-based Linux distribution optimized specifically for Amazon's platform). At the time of this writing, the most recent release of Amazon Linux AMI was 2012.09 (you might also want to take a quick look at Amazon Linux AMI 2012.03 Release Notes). In real life, it does not have to be an Amazon Linux AMI: any pre-built images (or even your own) can be used to create virtual machines.

Let's continue.

Here are the steps to create and launch an Amazon EC2 instance using an Amazon Linux AMI (or another AMI):
  1. In Amazon EC2 Console Dashboard (the default view of EC2 Management Console), click the "Launch Instance" button. This will bring up the "Create a New Instance" dialog. 
  2. In the "Create a New Instance" dialog, select "Classic Wizard" (default) and click the "Continue" button.
  3. In the next dialog, select "Amazon Linux AMI 2012.09" (it's the first one on the list) or whatever the most recent version might be at the time when you are reading this. Again, in real life, it doesn't have to be an Amazon Linux AMI, but, for the purpose of this tutorial, let's stick to the script.
  4. In the "Advanced Instance Options", leave everything as is, but tick the "Prevention against accidental termination" check box. Click "Continue".
  5. Under "Storage Device Configuration", accept the defaults and click "Continue".
  6. In the next dialog, under "Value", type in anything you want (e.g., "My Amazon EC2 Test"). Click "Continue".
  7. Create a new key pair. Call it whatever you want (e.g., myamazonsecret). Then, click the "Create & Download your Key Pair" button. The file myamazonsecret.pem (or whatever you called your key pair with the .pem extension) must be saved to your hard drive. This is your private key. Make sure you will be able to find it later!
  8. On the "Configure Firewall" dialog select the default security group without changing anything (for now) and click "Continue".
  9. On the "Review" dialog, click the "Launch" button.
  10. Simply close the next dialog.
  11. You are back to Amazon EC2 Console Dashboard. In the navigation side bar on the left, click "Instances"
  12. You should see your newly created instance listed. If it still says "Initializing" under "State", give it a couple of minutes. If you are an impatient type, you may click the "Refresh" button. Now, under "Status", it should say "Running".

You have just created and launched your first Amazon EC2 instance. In other words, you have created a remote virtual machine from a pre-built Linux "disk image", and this machine is now running on Amazon's virtualization platform. To simplify it even further, you now own a remote Linux computer. You can make it do whatever you want if you know how to administer it remotely, which, on a basic level, is not as scary as it sounds.

This feels like enough for the first session. So, for now, let's stop the instance (in other words, shut down the virtual machine). In order to do that, tick the check box next to the instance name and, from the "Instance Actions" drop-down list, select "Stop". It may take a minute or so for the instance to stop.

Sign out of your AWS account. By the way, you don't have to wait for the instance to actually stop before you sign out.

Go to Part 2.

No comments: