I am currently playing around with Amazon Web Services (AWS) to get some hands on experience in the cloud. Today I would like to share some of the gained knowledge about the first steps with AWS. This tutorial will mainly cover setting up an EC2 instance backed up by an EBS storage and how to work with that instance.
Time to sign up
Amazon is giving away some free stuff to new customers. Among those is a Amazon EC2 Linux Micro Instance that can be opearte 24/7 for a whole year, as well as 10 GB of Amazon Elastic Block Storage and some I/O opeartions on it. Basicly, they are giving away all you need to get a 100% free look into parts of AWS. So if you don’t have an account yet, sign up here.
Create a new instance
Now it is time to launch a new instance. Open the AWS Console and select the EC2 tab. Select your desired region to launch the instance within (blue circle) and afterwards click on launch instance (red circle).
Next, select the Basic 32-bit Amazon Linux AMI and continue.
In the following screen switch the instance type from a Small Instance to a Micro Instance. Leave the other options with their defaults and continue.
Neither do we want to change any advanced settings nor add any tags to the instance. Thus, skip the next two dialogs (click continue twice), till you reach the key-pair dialog. As we haven’t created any key pair yet, we will do so now. Select Create a new Key Pair (bule circle), type in any appropriate name for the key pair (red circle) and click on Create & Download your Key Pair (green circle). This will generate a new key pair and you will be asked to store it on your machine. Do so!
The next thing you need to do is set up a security group for the instance. As we don’t wont to go with the default one for now, you need to create a new group. Select Create a new Security Group (blue circle), give it an appropriate name and description (red circle). You need to define some allowed connections. Select HTTP from the drop-down (green circle) and click on Add Rule (yellow circle). Repeat the last step for HTTPS and SSH, so you end up with all three rules added to your security group. Click on continue to create the group.
On the final screen you are able to review all your inputs regarding the instance. A click on Launch will start the instance, which in fact will take a couple of minutes (sometimes only seconds). If you refresh the My Resources panel in AWS console your newly created instance as well as the created EBS storage, key pair and security group will show up eventually.
If you click on 1 Running Instance it will take you to the My Instances screen, where you can select your new instance and see all its details. Among these details is the Public DNS, note it down for later use!
Connecting to the instance
Once your instance is running, you might connect to it via SSH. If you are using Unix/Linux, I probably don’t need to tell you how you do that, just take the the public DNS and ssh to it. On Windows systems you might want to use Putty to get an SSH connection to your instance. On Keyword Intellect is a great blog post how to do that, so I wont repeat it here. One thing to add, make sure to log on as ec2-user not root.
Installing Apache HTTP Server on the instance
As an example we are going to install the Apache HTTP Server on the instance. Type the following line to install Apache and reply with y to all questions popping up.
sudo yum install httpd
After the installation is completed type the following statement to start Apache.
sudo /etc/init.d/httpd start
Go with your web browser to http://$YOUR-PUBLIC-DNS. You should see a page similar to the following. So now you know how to get started with Amazon Web Services, it is time for you work with your instance now. Enjoy!