Getting Started with AWS
Tags: aws, cloud, devops
Published: 2019-12-30 15:54:37

<h3>Introduction</h3>

<p>Today, we'll take some time to dive into <strong>Amazon Web Services</strong>.</p> 

<p>Often shortened to AWS, this is a cloud-computing platform that offers compute power, storage, content delivery and various other services on a pay-as-you-go basis.</p>

<p>We will consider:</p>

<ul><li>Why AWS?</li><li>Tracking your AWS Costs</li><li>Launching a Linux Virtual Server</li><li>Connecting to your Virtual Server</li><li>Terminating your Virtual Server</li></ul>

<h3>Why AWS?</h3>

<p>Part of what makes this platform special is the AWS Free Tier, which gives you access to the main functionality of AWS's services at a reasonable cost (typically free, unless you exceed certain thresholds on computing time, storage space and other metrics, in which case you are charged at the normal AWS rate).</p>

<p>This gives people like me the ability to experiment and explore with cloud computing and Amazon's bespoke offerings without needing to commit to lengthy contracts or payment plans. Before platforms like this existed, I would have to look into renting a server with an up-front cost (often with 12-24 month minimum terms), which would be ridiculous if I simply wanted to practice running a few SSH commands or writing a small ARM program.</p>

<p>Other solutions include running a virtual machine on my own computer, which is impractical for learning networking since it would be locally hosted; and purchasing my own hardware in order to run a physical server, which has the obvious issues of cost and storage, as well as deeper issues with scalability and even networking (the server won't have its own dedicated IP without going to my internet service provider).</p>

<h3>Tracking your AWS Costs</h3>

<p>AWS offers many <a href="https://aws.amazon.com/free/">Free Tier</a> options, and there is a mixture of 'Always Free', '12-Months Free' and 'Free Trial' choices available. Generally speaking, basic services such as database hosting are Always Free, advanced services such as machine learning platforms offer a Free Trial, and 'consumable services' such as storage and server hosting are free to use during your first 12 months.</p>

<p>AWS Budgets, which is another AWS service, allows you to monitor your service usage and costs by setting budgeted thresholds that can alert you if you cross them or are forecasted to do so. In order to track service costs in general, you can access the Billing Dashboard at any point, which offers great tracking tools such as checking your past costs, to-date costs and forecasted costs.</p>

<h3>Launching a Linux Virtual Machine</h3>

<p>We will be launching an EC2 instance. This is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the AWS infrastructure.</p>

<p>Using the Management Console, you can select the EC2 Service Console, and then use this console to launch an instance. This virtual server will get its own vCPU, memory and storage, as well as an IPv4 address for easily communicating with it, which we will achieve using SSH.</p>

<p>You will be prompted to choose a server template, which is a preconfigured server made up of an operating system (i.e. Amazon Linux) and often some additional programs. As well as the free options, there is an AMI Marketplace for other vendors, such as Microsoft, who may offer server images with more premium operating systems or support, such as Windows Server 2019, at an additional cost.</p>

<p>There are also 'Community AMIs', which are preconfigured server images created by other users that have had their visibility set to Public. These have the potential to be dangerous, and so should not be used unless the source is trusted. Since it's our first time on AWS, we can ignore these for now.</p>

<p>For now, select the newest Amazon Linux AMI, and then select the Free Tier-eligible instance type, which is <em>t2.micro</em>. This gives us 1 vCPU at up to 2.5GHz, 1 GiB memory and 8 GiB storage. Accept all of the default settings and launch the instance.</p>

<p>You will be prompted to create a key-pair, which is a secure way of accessing your instance via SSH. A key-pair consists of a public key (like a lock, held by AWS), and a private key (like a physical key, held by you). Losing this private key will render you unable to access the server, and giving it to someone else will allow them to access the server, so this key must be kept both safe and secure. </p>

<h3>Connecting to your Virtual Machine</h3>

<p>Now that our virtual machine has been set up, we can connect to it. Navigate to the 'instances' section of the EC2 Console and wait until the instance is ready. Then, take the IP address so that we can connect to it via SSH.</p>

<p>If you do not have SSH set up on your own computer, simply download and install Git Bash, which is a great tool for interfacing with operating systems. Git Bash will give you a command prompt, which we can use to connect with our server by typing:</p>

<pre class="wp-block-code"><code>ssh -i 'c:\Users\yourusername\.ssh\MyKeyPair.pem' ec2-user@{IP_Address}</code></pre>

<p>Your command will look something like this:</p>

<pre class="wp-block-code"><code>ssh -i 'c:\Users\LloydTao\.ssh\MyKeyPair.pem' ec2-user@{123.45.67.89}</code></pre>

<p>Your command prompt will give you a warning when successfully connecting for the first time, which is standard protocol in order to stop you from accidentally connecting to the wrong host. </p>

<p>Accepting the warning will add this host to the list of known hosts. A small bit of text should print in the command prompt, which means that you have successfully connected!</p>

<h3>Terminating an Instance</h3>

<p>We likely don't want to do anything more with this instance, so we should Terminate it to avoid accidentally incurring costs. It's an unlikely event, but still good practice.</p>

<p>Terminating an instance destroys it completely, including wiping its local storage from the root and rendering you unable to access it anymore.  If you want to simply take the server offline to be re-started another time, you can use the Stop action.  </p>

<p>Termination, as opposed to Stopping, is extremely useful for EC2 instances when scaling (e.g. when terminating excess servers while scaling-in). Data is typically stored in an Amazon S3 (Simple Storage Service) instance and not locally.</p>

<h3>Conclusion</h3>

<p>We have now learnt about the AWS Free Tier and billing management, and proceeded to launch a Linux Virtual Machine, connect to it via SSH and terminate the instance. A very productive first session!</p>