So far I have chosen AWS as my supplier, signed up for an AWS account and had a look at the console. I have not yet run a virtual machine, let alone built a resilient system – there are a few more building blocks to collect before I build the first load-balanced web servers. So far, I have not spent a bean.
I want to create a new virtual machine then destroy it. I am not going to put any work into this machine so there is no point saving it – another machine can be created immediately to take its place. I don’t care about checking the performance, persistence, load balancing or anything remotely usable at this stage. I don’t even care about the OS so I am going to go for the free “Basic 32-bit Amazon Linux AMI” (Amazon Machine Image). The Windows server may be more familiar to people, but it is not free.
Amazon uses public key cryptography to secure their machines. The first time you create a virtual machine you must also create private and public keys.
The console is often updated. I have been using the classic wizard. Now there is a Quick Launch wizard, as you can see below:
Click to enlarge.
Create an EC2 machine
- Open the AWS console.
- Click the Launch Instance button. A Request Instances Wizard opens. A few Quick Start virtual machine images are listed.
- Select an AMI. Select the Basic 32-bit Amazon Linux AMI. An Instance Details form appears.
- Submit the three pages of the instance form. I chose one micro instance and left the defaults for availability zone, kernel ID, shutdown behaviour, and so on.
- Create a key pair. Type in a name, Amazon generates the public and private keys, and hands over a text file containing the private key. The text looks a bit like this: many lines of Base64 encoded binary data.
—–BEGIN RSA PRIVATE KEY—–
+0ub9NRrWYDrreZ2WgvY83ussRWbS9bG2CoArIEcuwpZgzFisjDc2a2bKc/
d0Q4KjnUHuGMZxxCwFm/pBlHuIs8/plQQpjO9jph/oVtTR1OBNaFjMWnp60
eccKAD5J9KZGRStojgzB4rCPGTgG1e2crcVoQldUQ5YRtGE1APnZMw7+oIH
mdHLMcuI8aCpdGLJWrbSRRcQylhMTezGPvsqdh/Gr43wLtjAX/RjP2sRiEQ
15nFOZW9W+RRIvLkrxlgMNuuEuUpJ9PP+zGB71V9GatdoN2luYCV6QIDAQA
vkaBhTQrMd+LuqYvkQsjmbwp5GGPp3ywRcFrBAZeQ/BCHOj6iJchv5rvhR4
—–END RSA PRIVATE KEY—–
- Save the file somewhere safe. You will need it later, when you use SSH to log into your virtual machine. I saved mine as “aws-privkey-for-planetlarg.pem”.
- Configure the firewall. I accepted the “quick-start-1” security group. The Review page appears.
- Launch your new instance. Success!
- Close the wizard window. The console reappears.
I am now dipping into one of the many vast resource pools of the expensive, powerful and mysterious AWS data centres. When I hit that launch button I am guessing AWS machines carry out many tasks like these.
- Network configuration. AWS reserves a private IP address and public IP address, adds NAT (Network Address Translation), and other data network business to its network devices.
- Internet service configuration. AWS reserves and propagates DNS names for each IP address.
- Virtual Machine configuration. AWS makes a new copy of the Basic AMI, customises it, fires it up and makes it accessible to the outside Internet world.
- Management reporting. AWS finally adds this information for me to see in the console.
And all without human intervention. In fact, two high points here are the lack of configuration work for me to do and the absence of human co-workers telling me why I can’t have my machine.
Find the FQDN of the EC2 machine
The FQDN (Fully Qualified Domain Name) is the address that clients need to send requests to an EC2 machine. That includes me – I need a name later to feed to my SSH client.
This machine’s name is “ec2-46-137-5-45.eu-west-1.compute.amazonaws.com”. This suggests to me the factory-fitted format is (AWS service)-(IP address).(availability zone).compute.amazonaws.com.
Before I find this FQDN I check what the console says about my new machine. There is a section in the console titled My Resources, which displays a slightly worrying “0 Running Instances”.
- Click the Refresh button. The message changes to “1 Running Instance”.
- Click on this message and a My Instances table appears with a whole one row.
- Click the checkbox at the start of the row. A lot of information appears in the pane below the table.
- Find the Public DNS name. Mine is “ec2-46-137-5-45.eu-west-1.compute.amazonaws.com”.
Destroy the EC2 machine.
- Return to the My Instances table.
- Destroy the virtual machine. Click the Instance Actions link then Terminate from the drop-down menu. An “Are you sure” warning box appears.
- Confirm. The status of the instance changes to “shutting-down”, then “terminated”.
- Close the AWS console.