DEV Community

Cover image for Getting Started with AWS
Lewis Lloyd
Lewis Lloyd

Posted on

Getting Started with AWS

Introduction

Today, we'll take some time to dive into Amazon Web Services.

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.

We will consider:

  • Why AWS?
  • Tracking your AWS Costs
  • Launching a Linux Virtual Server
  • Connecting to your Virtual Server
  • Terminating your Virtual Server

Why AWS?

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).

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.

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).

Tracking your AWS Costs

AWS offers many Free Tier 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.

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.

Launching a Linux Virtual Machine

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.

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.

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.

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.

For now, select the newest Amazon Linux AMI, and then select the Free Tier-eligible instance type, which is t2.micro. 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.

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.

Connecting to your Virtual Machine

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.

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:

ssh -i 'c:\Users\yourusername\.ssh\MyKeyPair.pem' ec2-user@{IP_Address}

Your command will look something like this:

ssh -i 'c:\Users\LloydTao\.ssh\MyKeyPair.pem' ec2-user@{123.45.67.89}

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.

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!

Terminating an Instance

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.

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.

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.

Conclusion

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!

Discussion (1)

Collapse
094459 profile image
Ricardo Sueiras

Great post