Step 2 – HARD
Creating a cloud server using Amazon AWS can be easy, if you’re used to it.
As stated in the introduction post, instead of buying a physical server, we’re going to set up our server in the “cloud”. The cloud service we will be using is Amazon AWS. It’s basically the gold standard for most large corporations, provides an amazing number of services, and gives you full control over your server, its size, pricing options, etc. The best thing is, you won’t have to worry about physical server hardware ever. You can simply increase or decrease your server size as needed, and pay for what you use. That’s great when you’re starting out small, and hoping to grow.
First thing we’ll do is log into the AWS console with our account here: AWS Management Console.
Once logged in, you’ll see a very large list of services (shown below). The services we’re interested in are: EC2, Route 53, and RDS. For this step however, we’re only interested in EC2. For those of you unfamiliar with the acronym, EC2 means: Elastic Compute Cloud, or: create a cloud as big or as small as you want 🙂 Please click on the EC2 link. Use the search bar provided if you are unable to find it.
Once you’ve made it to the EC2 instances dashboard, click the “Instances” link on the left. I have 3 instances running currently, but you won’t have any yet (if you do, why are you reading this blog post?). Click on the blue “Launch Instance” button and choose “Launch Instance”. This will bring you to a list of “Amazon Machine Image” types.
As you can see, there are TONS of options. But we’re simple folk, so we’ll choose the latest LTS Ubuntu server. At time of this writing, that would be: “Ubuntu Server 18.04 LTS (HVM), SSD Volume Type – ami-0bbe6b35405ecebdb”. If you can’t find it in the list, copy and past the AMI id in the screenshot into the search field: ami-0bbe6b35405ecebdb. You should see a screen similar to mine on the left. Select that AMI.
Now we choose the instance type. To put another way, we choose how big we want our server to be. Feel free to experiment with different sizes and select the right fit for you. Remember, the larger the instance size, the more you’ll be paying for it on a monthly basis. In most cases, new websites and blogs can get away with a micro instance. You may even want to try a nano instance. Once you’re happy, click Review and Launch.
Feel free to ignore the “Review Instance Launch” screen. It provides important technical information about your instance which you already know, or don’t care to know. Simply click the Launch button in the lower right. This will bring up a new dialog in which you will create a key pair for your instance. The key pair is important, as it allows you to connect to your server.
Warning: if you lose your key pair, you will NEVER be able to connect to your instance again. You’ll have to start from scratch (which is a bummer). So store your key pair in a safe place!
Now that you’ve been warned, let’s generate our first key pair by selecting the “Create a new key pair” option, entering a creative name like “MY_SERVER_KEY_PAIR”, and click the Download Key Pair button. Once downloaded, store the MY_SERVER_KEY_PAIR.pem file in a safe place. You’ll need it every time you connect to your server through FileZilla FTP and Terminal. Next, click Launch Instances and allow AWS to do it’s thing.
From the Launch Status page, click View Instances. This will take you back to the ECS Instances dashboard. You’ll notice that in the Status Checks column, your instance will be Initializing.
This is a great time to take a moment and appreciate what AWS is doing for you. First of all, they’re provisioning hardware on your behalf and assigning it an IP address. Second, they’re installing the AMI you selected earlier, applying a default security group, making your instance accessible, etc. And if you want… you can select your instance and terminate it. Hardware will free up, the IP you were assigned will go back into the pool, and you can start all over again. This crap is amazing…
Now is also a great time to give your instance a name. I’ve named mine SAMPLE_SERVER. But maybe you’ll want something more meaningful, like: INFINITE_DAB_PROD. Click on the little pencil icon shown below to open the edit field. Creating a meaningful name will prevent you from accidentally terminating your instance later, should you have multiple instances running.
Now that your instance is up and running, let’s connect to it. With the instance selected (blue dot on the left), press the Connect button at the top. It will open the following dialog box telling you how to connect. This is where our Terminal application comes into the picture.
The instructions provided say it all, but I’ll reiterate: Open an SSH client (the Terminal application), then run the example SSH command. Note that the file “MY_SERVER_KEY_PAIR.pem” should be in the same folder that you’re executing the command from. On my device, we default to the “home” folder, so I’ve copied the file there. Full path to the file looks like: /home/MY_SERVER_KEY_PAIR.pem. Execute the command like so:
A lot of the information provided in the terminal will not be interesting to you, so you can ignore it. What you’re looking for is a successful connection as indicated by the green line at the bottom: ubuntu@ip-172-31-19-107:~$ This indicates that you’re connected and able to execute commands as the “ubuntu” user. Type “exit” into the terminal if you wish to disconnect for now.
Note: Not shown here is an additional step in which the terminal application asked me if I want to trust this host. The answer to this is yes, or else we will not be able to connect. So type “yes” into the terminal if prompted.
You’ve completed step 2, which is ranked at HARD difficulty. Now onto step 3.